Refactoring

This commit is contained in:
Chris Mann 2023-07-26 11:27:49 +02:00
parent 7c70657127
commit a7fd521f62
4 changed files with 28 additions and 27 deletions

View file

@ -34,8 +34,8 @@
<input type="text" id="surname" name="surname" class="form-control" value="{{ .Surname }}" /> <input type="text" id="surname" name="surname" class="form-control" value="{{ .Surname }}" />
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="otheremail">Email de secours:</label> <label for="othermailbox">Email de secours:</label>
<input type="text" id="otheremail" name="otheremail" class="form-control" value="{{ .OtherEmail }}" /> <input type="text" id="othermailbox" name="othermailbox" class="form-control" value="{{ .OtherMailbox }}" />
<small class="form-text text-muted"> <small class="form-text text-muted">
Le courriel de l'utilisateur. Le courriel de l'utilisateur.
</small> </small>

View file

@ -202,7 +202,7 @@ func handleNewAccount(w http.ResponseWriter, r *http.Request, l *ldap.Conn, invi
newUser.GivenName = strings.TrimSpace(strings.Join(r.Form["givenname"], "")) newUser.GivenName = strings.TrimSpace(strings.Join(r.Form["givenname"], ""))
newUser.SN = strings.TrimSpace(strings.Join(r.Form["surname"], "")) newUser.SN = strings.TrimSpace(strings.Join(r.Form["surname"], ""))
newUser.Mail = strings.TrimSpace(strings.Join(r.Form["mail"], "")) newUser.Mail = strings.TrimSpace(strings.Join(r.Form["mail"], ""))
newUser.UID = strings.TrimSpace(strings.Join(r.Form["otheremail"], "")) newUser.UID = strings.TrimSpace(strings.Join(r.Form["othermailbox"], ""))
newUser.CN = strings.TrimSpace(strings.Join(r.Form["username"], "")) newUser.CN = strings.TrimSpace(strings.Join(r.Form["username"], ""))
newUser.DN = "cn=" + strings.TrimSpace(strings.Join(r.Form["username"], "")) + "," + config.InvitationBaseDN newUser.DN = "cn=" + strings.TrimSpace(strings.Join(r.Form["username"], "")) + "," + config.InvitationBaseDN

View file

@ -45,7 +45,7 @@ func handleUser(w http.ResponseWriter, r *http.Request) {
data.DisplayName = login.UserEntry.GetAttributeValue("displayName") data.DisplayName = login.UserEntry.GetAttributeValue("displayName")
data.GivenName = login.UserEntry.GetAttributeValue("givenName") data.GivenName = login.UserEntry.GetAttributeValue("givenName")
data.Surname = login.UserEntry.GetAttributeValue("sn") data.Surname = login.UserEntry.GetAttributeValue("sn")
data.OtherEmail = login.UserEntry.GetAttributeValue("carLicense") data.OtherMailbox = login.UserEntry.GetAttributeValue("carLicense")
// data.Visibility = login.UserEntry.GetAttributeValue(FIELD_NAME_DIRECTORY_VISIBILITY) // data.Visibility = login.UserEntry.GetAttributeValue(FIELD_NAME_DIRECTORY_VISIBILITY)
data.Description = login.UserEntry.GetAttributeValue("description") data.Description = login.UserEntry.GetAttributeValue("description")
//data.ProfilePicture = login.UserEntry.GetAttributeValue(FIELD_NAME_PROFILE_PICTURE) //data.ProfilePicture = login.UserEntry.GetAttributeValue(FIELD_NAME_PROFILE_PICTURE)
@ -54,15 +54,16 @@ func handleUser(w http.ResponseWriter, r *http.Request) {
//5MB maximum size files //5MB maximum size files
r.ParseMultipartForm(5 << 20) r.ParseMultipartForm(5 << 20)
user := User{ user := User{
DN: login.Info.DN, DN: login.Info.DN,
// CN: , GivenName: strings.TrimSpace(strings.Join(r.Form["given_name"], "")),
GivenName: strings.TrimSpace(strings.Join(r.Form["given_name"], "")), DisplayName: strings.TrimSpace(strings.Join(r.Form["display_name"], "")),
DisplayName: strings.TrimSpace(strings.Join(r.Form["display_name"], "")), Mail: strings.TrimSpace(strings.Join(r.Form["mail"], "")),
Mail: strings.TrimSpace(strings.Join(r.Form["mail"], "")), SN: strings.TrimSpace(strings.Join(r.Form["surname"], "")),
SN: strings.TrimSpace(strings.Join(r.Form["surname"], "")), OtherMailbox: strings.TrimSpace(strings.Join(r.Form["othermailbox"], "")),
//UID: , Description: strings.TrimSpace(strings.Join(r.Form["description"], "")),
Description: strings.TrimSpace(strings.Join(r.Form["description"], "")),
// Password: , // Password: ,
//UID: ,
// CN: ,
} }
if user.DisplayName != "" { if user.DisplayName != "" {

30
view.go
View file

@ -150,13 +150,13 @@ type PasswordLostData struct {
OtherMailbox string OtherMailbox string
} }
type NewAccountData struct { type NewAccountData struct {
Username string Username string
DisplayName string DisplayName string
GivenName string GivenName string
Surname string Surname string
Mail string Mail string
SuggestPW string SuggestPW string
OtherEmail string OtherMailbox string
ErrorUsernameTaken bool ErrorUsernameTaken bool
ErrorInvalidUsername bool ErrorInvalidUsername bool
@ -182,14 +182,14 @@ type CodeMailFields struct {
Common NestedCommonTplData Common NestedCommonTplData
} }
type ProfileTplData struct { type ProfileTplData struct {
Mail string Mail string
DisplayName string DisplayName string
GivenName string GivenName string
Surname string Surname string
Description string Description string
OtherEmail string OtherMailbox string
Common NestedCommonTplData Common NestedCommonTplData
Login NestedLoginTplData Login NestedLoginTplData
} }
//ProfilePicture string //ProfilePicture string