save session key

This commit is contained in:
sentriz
2019-04-18 11:22:04 +01:00
parent e8424ca571
commit c6273c8c12
3 changed files with 37 additions and 24 deletions

View File

@@ -93,14 +93,16 @@ func (c *Controller) ServeLinkLastFMCallback(w http.ResponseWriter, r *http.Requ
secret.Value,
token,
)
session := r.Context().Value("session").(*sessions.Session)
if err != nil {
session := r.Context().Value("session").(*sessions.Session)
session.AddFlash(err.Error())
session.Save(r, w)
http.Redirect(w, r, "/admin/home", 302)
return
}
fmt.Println("THE SESSION KEY", sessionKey)
user, _ := session.Values["user"].(*db.User)
user.LastFMSession = sessionKey
c.DB.Save(&user)
http.Redirect(w, r, "/admin/home", 302)
}