Refactoring

This commit is contained in:
Chris Mann 2023-07-26 11:36:51 +02:00
parent a7fd521f62
commit cb57eeea47
5 changed files with 12 additions and 0 deletions

View file

@ -147,6 +147,7 @@ func modify(user User, config *ConfigFile, ldapConn *ldap.Conn) error {
replaceIfContent(modify_request, "displayName", user.DisplayName, previousUser.DisplayName)
replaceIfContent(modify_request, "givenName", user.GivenName, previousUser.GivenName)
replaceIfContent(modify_request, "sn", user.SN, previousUser.SN)
replaceIfContent(modify_request, "carLicense", user.OtherMailbox, user.OtherMailbox)
replaceIfContent(modify_request, "description", user.Description, previousUser.Description)
err = ldapConn.Modify(modify_request)
if err != nil {

View file

@ -58,6 +58,11 @@
<input type="text" id="mail" name="mail" class="form-control" value="{{ .Mail }}" />
</div>
<input type="hidden" name="mail" value="" />
<div class="form-group">
<label for="othermailbox">Email de secours:</label>
<input type="text" id="othermailbox" name="othermailbox" class="form-control" value="{{ .OtherMailbox }}" />
</div>
<input type="hidden" name="mail" value="" />
<div class="form-group">
<label for="givenname">Prénom :</label>
<input type="text" id="givenname" name="givenname" class="form-control" value="{{ .GivenName }}" />

View file

@ -937,6 +937,7 @@ func handleAdminCreate(w http.ResponseWriter, r *http.Request) {
data.Member = strings.TrimSpace(strings.Join(r.Form["member"], ""))
data.Description = strings.TrimSpace(strings.Join(r.Form["description"], ""))
data.SN = strings.TrimSpace(strings.Join(r.Form["sn"], ""))
data.OtherMailbox = strings.TrimSpace(strings.Join(r.Form["othermailbox"], ""))
object_class := []string{}
for _, oc := range strings.Split(data.ObjectClass, "\n") {
@ -993,6 +994,9 @@ func handleAdminCreate(w http.ResponseWriter, r *http.Request) {
newUser.SN = data.SN
// req.Attribute("sn", []string{data.SN})
}
if data.OtherMailbox != "" {
newUser.OtherMailbox = data.OtherMailbox
}
if data.Description != "" {
newUser.Description = data.Description
// req.Attribute("description", []string{data.Description})

View file

@ -201,6 +201,7 @@ func handleNewAccount(w http.ResponseWriter, r *http.Request, l *ldap.Conn, invi
newUser.DisplayName = strings.TrimSpace(strings.Join(r.Form["displayname"], ""))
newUser.GivenName = strings.TrimSpace(strings.Join(r.Form["givenname"], ""))
newUser.SN = strings.TrimSpace(strings.Join(r.Form["surname"], ""))
newUser.OtherMailbox = strings.TrimSpace(strings.Join(r.Form["othermailbox"], ""))
newUser.Mail = strings.TrimSpace(strings.Join(r.Form["mail"], ""))
newUser.UID = strings.TrimSpace(strings.Join(r.Form["othermailbox"], ""))
newUser.CN = strings.TrimSpace(strings.Join(r.Form["username"], ""))

View file

@ -113,6 +113,7 @@ type CreateData struct {
StructuralObjectClass string
ObjectClass string
SN string
OtherMailbox string
Common NestedCommonTplData
Login NestedLoginTplData