func getSessionUser(session sessions.Session, dbh *db.Dbh) (user models.User) { var email, sessionkey, loggedin string var suid int64 sloggedin := session.Get("loggedin") if sloggedin != nil { loggedin = sloggedin.(string) } semail := session.Get("email") if semail != nil { email = semail.(string) } ssessionkey := session.Get("key") if ssessionkey != nil { sessionkey = ssessionkey.(string) } ssuid := session.Get("uid") if ssuid != nil { suid = ssuid.(int64) } if loggedin != "true" || sessionkey == "" { return } usk := dbh.GetUserByIdSessionKey(suid, sessionkey) if usk.Active != true || usk.Id < 1 { return } u := dbh.GetUserById(suid) if u.Email != email { return } return u }