From f929ca7297905e4233aa32fe2d80dd4cc3fcda30 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Sun, 9 Feb 2020 19:56:01 +0100 Subject: Uniformize templates --- admin.go | 10 ++++---- profile.go | 13 ++++++---- templates/admin_users.html | 2 ++ templates/home.html | 2 +- templates/passwd.html | 22 ++++++++++------- templates/profile.html | 60 ++++++++++++++++++++++------------------------ 6 files changed, 58 insertions(+), 51 deletions(-) diff --git a/admin.go b/admin.go index 60296dc..5a86fe2 100644 --- a/admin.go +++ b/admin.go @@ -1,9 +1,9 @@ package main import ( + "fmt" "html/template" "net/http" - "fmt" "sort" "github.com/go-ldap/ldap/v3" @@ -31,9 +31,9 @@ func checkAdminLogin(w http.ResponseWriter, r *http.Request) *LoginStatus { } type AdminUsersTplData struct { - Login *LoginStatus + Login *LoginStatus UserNameAttr string - Users []*ldap.Entry + Users []*ldap.Entry } func handleAdminUsers(w http.ResponseWriter, r *http.Request) { @@ -58,9 +58,9 @@ func handleAdminUsers(w http.ResponseWriter, r *http.Request) { } data := &AdminUsersTplData{ - Login: login, + Login: login, UserNameAttr: config.UserNameAttr, - Users: sr.Entries, + Users: sr.Entries, } sort.Sort(data) diff --git a/profile.go b/profile.go index 00e93dd..fa372bc 100644 --- a/profile.go +++ b/profile.go @@ -63,10 +63,11 @@ func handleProfile(w http.ResponseWriter, r *http.Request) { } type PasswdTplData struct { - Status *LoginStatus - ErrorMessage string - NoMatchError bool - Success bool + Status *LoginStatus + ErrorMessage string + TooShortError bool + NoMatchError bool + Success bool } func handlePasswd(w http.ResponseWriter, r *http.Request) { @@ -89,7 +90,9 @@ func handlePasswd(w http.ResponseWriter, r *http.Request) { password := strings.Join(r.Form["password"], "") password2 := strings.Join(r.Form["password2"], "") - if password2 != password { + if len(password) < 8 { + data.TooShortError = true + } else if password2 != password { data.NoMatchError = true } else { modify_request := ldap.NewModifyRequest(login.Info.DN, nil) diff --git a/templates/admin_users.html b/templates/admin_users.html index 8ca80e2..39e291c 100644 --- a/templates/admin_users.html +++ b/templates/admin_users.html @@ -1,7 +1,9 @@ {{define "title"}}Liste des utilisateurs |{{end}} {{define "body"}} +
+

Liste des utilisateurs

Retour
diff --git a/templates/home.html b/templates/home.html index 3f91e7b..b4012fd 100644 --- a/templates/home.html +++ b/templates/home.html @@ -1,7 +1,7 @@ {{define "title"}}{{end}} {{define "body"}} -
+
Bienvenue, {{ .Login.UserEntry.GetAttributeValue "givenname" }} !
diff --git a/templates/passwd.html b/templates/passwd.html index 57ae234..33953c8 100644 --- a/templates/passwd.html +++ b/templates/passwd.html @@ -1,24 +1,31 @@ {{define "title"}}Mot de passe |{{end}} {{define "body"}} -

Modifier mon mot de passe

+
+

Modifier mon mot de passe

+ Retour +
{{if .ErrorMessage}} -
Impossible d'effectuer la modification. +
Impossible d'effectuer la modification.
{{ .ErrorMessage }}
{{end}} {{if .Success}} -
+
Nouveau mot de passe enregistré.
- Retour {{else}} -
+
+ {{if .TooShortError}} +
+ Le mot de passe choisi est trop court (minimum 8 caractères). +
+ {{end}}
@@ -28,10 +35,7 @@ Les deux mots de passe entrés ne correspondent pas.
{{end}} -
- - Annuler -
+
{{end}} {{end}} diff --git a/templates/profile.html b/templates/profile.html index bdab685..d18c372 100644 --- a/templates/profile.html +++ b/templates/profile.html @@ -1,44 +1,42 @@ {{define "title"}}Profile |{{end}} {{define "body"}} -

Modifier mon profil

+
+

Modifier mon profil

+ Retour +
{{if .ErrorMessage}} -
Impossible d'effectuer la modification. +
Impossible d'effectuer la modification.
{{ .ErrorMessage }}
{{end}} {{if .Success}} -
+
Profil enregistré.
- Retour - {{else}} -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - Annuler -
-
{{end}} +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
{{end}} -- cgit v1.2.3