aboutsummaryrefslogtreecommitdiffstats
path: root/web.go
diff options
context:
space:
mode:
Diffstat (limited to 'web.go')
-rw-r--r--web.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/web.go b/web.go
index 5dc2e70..0810f76 100644
--- a/web.go
+++ b/web.go
@@ -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) {