Menu system conform / propagation CanAdmin

This commit is contained in:
Chris Mann 2023-07-24 11:12:46 +02:00
parent 9bbbfbe91a
commit 53d323570b
5 changed files with 23 additions and 10 deletions

View file

@ -75,6 +75,7 @@ func handleAdminActivateUsers(w http.ResponseWriter, r *http.Request) {
UserNameAttr: config.UserNameAttr,
UserBaseDN: config.UserBaseDN,
Users: EntryList(sr.Entries),
CanAdmin: login.CanAdmin,
}
templateAdminActivateUsers.Execute(w, data)
@ -134,6 +135,7 @@ func handleAdminUsers(w http.ResponseWriter, r *http.Request) {
UserNameAttr: config.UserNameAttr,
UserBaseDN: config.UserBaseDN,
Users: EntryList(sr.Entries),
CanAdmin: login.CanAdmin,
}
sort.Sort(data.Users)
@ -183,6 +185,7 @@ func handleAdminGroups(w http.ResponseWriter, r *http.Request) {
GroupNameAttr: config.GroupNameAttr,
GroupBaseDN: config.GroupBaseDN,
Groups: EntryList(sr.Entries),
CanAdmin: login.CanAdmin,
}
sort.Sort(data.Groups)
@ -223,6 +226,7 @@ func handleAdminMailing(w http.ResponseWriter, r *http.Request) {
MailingNameAttr: config.MailingNameAttr,
MailingBaseDN: config.MailingBaseDN,
MailingLists: EntryList(sr.Entries),
CanAdmin: login.CanAdmin,
}
sort.Sort(data.MailingLists)
@ -423,8 +427,9 @@ func handleAdminMailingList(w http.ResponseWriter, r *http.Request) {
PossibleNewMembers: possibleNewMembers,
AllowGuest: config.MailingGuestsBaseDN != "",
Error: dError,
Success: dSuccess,
Error: dError,
Success: dSuccess,
CanAdmin: login.CanAdmin,
}
sort.Sort(data.Members)
sort.Sort(data.PossibleNewMembers)
@ -910,8 +915,9 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) {
Groups: groups,
PossibleNewGroups: possibleNewGroups,
Error: dError,
Success: dSuccess,
Error: dError,
Success: dSuccess,
CanAdmin: true,
})
}
@ -1099,6 +1105,7 @@ func handleAdminCreate(w http.ResponseWriter, r *http.Request) {
// }
}
}
data.CanAdmin = true
templateAdminCreate.Execute(w, data)
}

View file

@ -22,9 +22,10 @@ func handleHome(w http.ResponseWriter, r *http.Request) {
}
data := &HomePageData{
Login: login,
BaseDN: config.BaseDN,
Org: config.Org,
Login: login,
BaseDN: config.BaseDN,
Org: config.Org,
CanAdmin: login.CanAdmin,
}
templateHome.Execute(w, data)

View file

@ -103,6 +103,7 @@ func handleLostPassword(w http.ResponseWriter, r *http.Request) {
data.Success = true
}
}
data.CanAdmin = false
templateLostPasswordPage.Execute(w, data)
}
@ -251,6 +252,7 @@ func handleNewAccount(w http.ResponseWriter, r *http.Request, l *ldap.Conn, invi
} else {
data.SuggestPW = fmt.Sprintf("%s", suggestPassword())
}
data.CanAdmin = false
templateInviteNewAccount.Execute(w, data)
return data.Success
@ -411,6 +413,7 @@ func handleInviteSendCode(w http.ResponseWriter, r *http.Request) {
data.Success = true
data.CodeDisplay = code
}
data.CanAdmin = login.CanAdmin
templateInviteSendCode.Execute(w, data)

View file

@ -228,7 +228,7 @@ func handleLogin(w http.ResponseWriter, r *http.Request) *LoginInfo {
templateLogin := getTemplate("login.html")
if r.Method == "GET" {
templateLogin.Execute(w, LoginFormData{})
templateLogin.Execute(w, LoginFormData{CanAdmin: false})
return nil
} else if r.Method == "POST" {
// log.Printf("%v", "Parsing Form handleLogin")
@ -250,6 +250,7 @@ func handleLogin(w http.ResponseWriter, r *http.Request) *LoginInfo {
data := &LoginFormData{
Username: username,
Login: false,
CanAdmin: false,
}
if ldap.IsErrorWithCode(err, ldap.LDAPResultInvalidCredentials) {
data.WrongPass = true

View file

@ -39,7 +39,7 @@ func handleProfile(w http.ResponseWriter, r *http.Request) {
Login: login,
ErrorMessage: "",
Success: false,
CanAdmin: false,
CanAdmin: login.CanAdmin,
}
data.Mail = login.UserEntry.GetAttributeValue("mail")
@ -177,6 +177,7 @@ func handleFoundPassword(w http.ResponseWriter, r *http.Request) {
}
}
}
data.CanAdmin = false
templateFoundPasswordPage.Execute(w, data)
}
@ -216,6 +217,6 @@ func handlePasswd(w http.ResponseWriter, r *http.Request) {
}
}
}
data.CanAdmin = false
templatePasswd.Execute(w, data)
}