diff options
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -46,12 +46,15 @@ func (app *App) loginHandler(w http.ResponseWriter, r *http.Request) { if r.Method == http.MethodPost { username := r.FormValue("username") password := r.FormValue("password") + next := r.FormValue("next") hash := md5.Sum([]byte(password)) dst := make([]byte, hex.EncodedLen(md5.Size)) hex.Encode(dst, hash[:]) u, ok := app.GetUser(username) - next := r.FormValue("next") if ok && subtle.ConstantTimeCompare(u.Password, dst) == 1 { + s := app.NewSession(u.Id) + c := http.Cookie{Name: "id", Value: s.Id, Domain: ".horel.test"} + http.SetCookie(w, &c) http.Redirect(w, r, next, http.StatusSeeOther) } else { app.Template.ExecuteTemplate(w, "login.tmpl", struct { |
