rename GetUserFromName -> GetUserByName

This commit is contained in:
sentriz
2020-07-16 22:59:55 +01:00
parent 19e4958f2f
commit f34a0b48f9
5 changed files with 22 additions and 10 deletions

View File

@@ -21,7 +21,7 @@ func (c *Controller) WithUserSession(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// session exists at this point
session := r.Context().Value(CtxSession).(*sessions.Session)
username, ok := session.Values["user"].(string)
userID, ok := session.Values["user"].(int)
if !ok {
sessAddFlashW(session, []string{"you are not authenticated"})
sessLogSave(session, w, r)
@@ -29,7 +29,7 @@ func (c *Controller) WithUserSession(next http.Handler) http.Handler {
return
}
// take username from sesion and add the user row to the context
user := c.DB.GetUserFromName(username)
user := c.DB.GetUserByID(userID)
if user == nil {
// the username in the client's session no longer relates to a
// user in the database (maybe the user was deleted)