aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--data.go2
-rw-r--r--web.go10
2 files changed, 7 insertions, 5 deletions
diff --git a/data.go b/data.go
index 3ece80f..a447516 100644
--- a/data.go
+++ b/data.go
@@ -5,8 +5,6 @@ import (
"encoding/xml"
"log"
"time"
-
- _ "github.com/mattn/go-sqlite3"
)
type Scrobble struct {
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) {