From b8f125cb0f9c6ce426e3fdc7434d44a1ce7e16e4 Mon Sep 17 00:00:00 2001 From: Chris Mann Date: Sat, 22 Jul 2023 11:33:47 +0200 Subject: [PATCH] Factoring the model user and correcting password --- invite.go | 14 ++++--- model-user.go | 27 ++++++------- templates/invite_new_account.html | 65 +++++++++++++++++-------------- 3 files changed, 58 insertions(+), 48 deletions(-) diff --git a/invite.go b/invite.go index 4c33c99..e554f94 100644 --- a/invite.go +++ b/invite.go @@ -123,12 +123,13 @@ func handleInvitationCode(w http.ResponseWriter, r *http.Request) { // Common functions for new account type NewAccountData struct { - Username string - DisplayName string - GivenName string - Surname string - Mail string - SuggestPW string + Username string + DisplayName string + GivenName string + Surname string + Mail string + SuggestPW string + OtherMailbox string ErrorUsernameTaken bool ErrorInvalidUsername bool @@ -155,6 +156,7 @@ func handleNewAccount(w http.ResponseWriter, r *http.Request, l *ldap.Conn, invi newUser.GivenName = strings.TrimSpace(strings.Join(r.Form["givenname"], "")) newUser.SN = strings.TrimSpace(strings.Join(r.Form["surname"], "")) newUser.UID = strings.TrimSpace(strings.Join(r.Form["username"], "")) + newUser.OtherMailbox = strings.TrimSpace(strings.Join(r.Form["otherMailbox"], "")) newUser.Mail = strings.TrimSpace(strings.Join(r.Form["mail"], "")) newUser.DN = "cn=" + newUser.CN + "," + config.InvitationBaseDN diff --git a/model-user.go b/model-user.go index 4540e2c..0ee4d8d 100644 --- a/model-user.go +++ b/model-user.go @@ -15,18 +15,19 @@ import ( Represents a user */ type User struct { - DN string - CN string - GivenName string - DisplayName string - Mail string - SN string - UID string - Description string - Password string - CanAdmin bool - CanInvite bool - UserEntry *ldap.Entry + DN string + CN string + GivenName string + DisplayName string + Mail string + SN string + UID string + Description string + Password string + OtherMailbox string + CanAdmin bool + CanInvite bool + UserEntry *ldap.Entry } func get(user User, config *ConfigFile, ldapConn *ldap.Conn) (*User, error) { @@ -85,7 +86,7 @@ func add(user User, config *ConfigFile, ldapConn *ldap.Conn) error { dn := user.DN req := ldap.NewAddRequest(dn, nil) - req.Attribute("objectClass", []string{"top", "inetOrgPerson"}) + req.Attribute("objectClass", []string{"top", "inetOrgPerson", "pilotPerson"}) if user.DisplayName != "" { req.Attribute("displayName", []string{user.DisplayName}) } diff --git a/templates/invite_new_account.html b/templates/invite_new_account.html index d02fad3..85dbed4 100644 --- a/templates/invite_new_account.html +++ b/templates/invite_new_account.html @@ -22,17 +22,6 @@ {{else}}
-
- - -
-
- - - - Le courriel de l'utilisateur. - -
@@ -41,6 +30,17 @@
+
+ + + + Le courriel de l'utilisateur. + +
+
+ + +
@@ -61,6 +61,13 @@ Ce nom d'utilisateur est déjà pris.
{{end}} +
+ + + + Le courriel et login interne. + +

Utiliser ce mot de passe : {{ .SuggestPW }}

@@ -88,27 +95,27 @@