diff options
| author | Thibaut Horel <thibaut.horel@gmail.com> | 2017-06-13 20:42:22 -0400 |
|---|---|---|
| committer | Thibaut Horel <thibaut.horel@gmail.com> | 2017-06-13 20:42:22 -0400 |
| commit | a64a435757ab96cdd73ae83903242406bbb258f8 (patch) | |
| tree | bd1d123e195e3d7460e86e1ecd0a46b84d685693 /web.go | |
| parent | a38f778312b392614ec0ccf14f9f2790671b63eb (diff) | |
| download | lastfm-api-a64a435757ab96cdd73ae83903242406bbb258f8.tar.gz | |
Fix broken login
Diffstat (limited to 'web.go')
| -rw-r--r-- | web.go | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -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) { |
