diff options
| author | Thibaut Horel <thibaut.horel@gmail.com> | 2018-12-31 06:43:36 -0500 |
|---|---|---|
| committer | Thibaut Horel <thibaut.horel@gmail.com> | 2018-12-31 06:43:36 -0500 |
| commit | 6ae97fe4d7c4fa1c80571d41c356453199041067 (patch) | |
| tree | ae3492fb014c9c1017f74dc6ae59b363b8f423db /main.go | |
| parent | b8a240fdf4f0496271ad7d2b04bc663473ff889d (diff) | |
| download | id-6ae97fe4d7c4fa1c80571d41c356453199041067.tar.gz | |
Add error messages in login page
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -75,15 +75,23 @@ func (app *App) loginHandler(w http.ResponseWriter, r *http.Request) { http.SetCookie(w, &c) http.Redirect(w, r, next, http.StatusSeeOther) } else { + var flash string + if !ok { + flash = "Utilisateur non enregistré" + } else if subtle.ConstantTimeCompare(u.Password, hash) != 1 { + flash = "Mot de passe incorrect" + } app.Template.ExecuteTemplate(w, "login.tmpl", struct { - Next string - }{next}) + Next string + Flash string + }{next, flash}) } } else if r.Method == http.MethodGet { next := r.FormValue("next") app.Template.ExecuteTemplate(w, "login.tmpl", struct { - Next string - }{next}) + Next string + Flash string + }{next, ""}) } } |
