aboutsummaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
authorThibaut Horel <thibaut.horel@gmail.com>2018-12-31 06:43:36 -0500
committerThibaut Horel <thibaut.horel@gmail.com>2018-12-31 06:43:36 -0500
commit6ae97fe4d7c4fa1c80571d41c356453199041067 (patch)
treeae3492fb014c9c1017f74dc6ae59b363b8f423db /main.go
parentb8a240fdf4f0496271ad7d2b04bc663473ff889d (diff)
downloadid-6ae97fe4d7c4fa1c80571d41c356453199041067.tar.gz
Add error messages in login page
Diffstat (limited to 'main.go')
-rw-r--r--main.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/main.go b/main.go
index 34667cf..86fd969 100644
--- a/main.go
+++ b/main.go
@@ -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, ""})
}
}