diff options
| -rw-r--r-- | data.go | 2 | ||||
| -rw-r--r-- | web.go | 10 |
2 files changed, 7 insertions, 5 deletions
@@ -5,8 +5,6 @@ import ( "encoding/xml" "log" "time" - - _ "github.com/mattn/go-sqlite3" ) type Scrobble struct { @@ -78,18 +78,22 @@ func (app *App) callback(w http.ResponseWriter, r *http.Request) { json.Unmarshal(p, user) s := &UserSession{Id: hex.EncodeToString(genKey(32))} + var newUser bool if err := app.GetUser(user); err != nil { + newUser = true if err := app.InsertUser(user); err != nil { panic(err) } - http.Redirect(w, r, "/settings", http.StatusTemporaryRedirect) - } else { - http.Redirect(w, r, "/", http.StatusFound) } s.UserId = user.Id s.UserName = user.Name app.InsertUserSession(s) app.SetCookie(w, "session", s, 86400*30) + if newUser { + http.Redirect(w, r, "/settings", http.StatusTemporaryRedirect) + } else { + http.Redirect(w, r, "/", http.StatusFound) + } } func (app *App) settings(w http.ResponseWriter, r *http.Request) { |
