func LoginPost(lu forms.Login, session sessions.Session, r render.Render, dbh *db.Dbh) { errs := ValidateLogin(&lu) if len(errs) > 0 { log.Printf("errors: %+v\n", errs) } user := dbh.GetUserByEmail(lu.Email) match := auth.MatchPassword(lu.Password, user.Password, user.Salt) if match { sessionkey := SessionKey(user.Email, user.Password, user.Salt) session.Set("loggedin", "true") session.Set("uid", user.Id) session.Set("email", user.Email) session.Set("key", sessionkey) dbh.CreateSession(models.UserSession{UserId: user.Id, SessionKey: sessionkey, Active: true, Timestamp: time.Now().Unix()}) r.Redirect(strings.Join([]string{utils.AppCfg.Url(), "albums"}, "/"), http.StatusFound) return } session.Set("flash", "Invalid Email or Password") r.Redirect(strings.Join([]string{utils.AppCfg.Url(), "login"}, "/"), http.StatusFound) }