Fixed Change Password Bug

This commit is contained in:
Chris Mann 2023-07-24 16:28:22 +02:00
parent 60b204b82f
commit 900b75738f
5 changed files with 30 additions and 19 deletions

View file

@ -44,6 +44,7 @@ type AdminUsersTplData struct {
UserBaseDN string
Users EntryList
CanAdmin bool
LoggedIn bool
}
func handleAdminActivateUsers(w http.ResponseWriter, r *http.Request) {
@ -76,6 +77,7 @@ func handleAdminActivateUsers(w http.ResponseWriter, r *http.Request) {
UserBaseDN: config.UserBaseDN,
Users: EntryList(sr.Entries),
CanAdmin: login.CanAdmin,
LoggedIn: bool,
}
templateAdminActivateUsers.Execute(w, data)
@ -136,6 +138,7 @@ func handleAdminUsers(w http.ResponseWriter, r *http.Request) {
UserBaseDN: config.UserBaseDN,
Users: EntryList(sr.Entries),
CanAdmin: login.CanAdmin,
LoggedIn: false,
}
sort.Sort(data.Users)
@ -157,6 +160,7 @@ type AdminGroupsTplData struct {
GroupBaseDN string
Groups EntryList
CanAdmin bool
LoggedIn bool
}
func handleAdminGroups(w http.ResponseWriter, r *http.Request) {
@ -186,6 +190,7 @@ func handleAdminGroups(w http.ResponseWriter, r *http.Request) {
GroupBaseDN: config.GroupBaseDN,
Groups: EntryList(sr.Entries),
CanAdmin: login.CanAdmin,
LoogedIn: false,
}
sort.Sort(data.Groups)
@ -198,6 +203,7 @@ type AdminMailingTplData struct {
MailingBaseDN string
MailingLists EntryList
CanAdmin bool
LoggedIn bool
}
func handleAdminMailing(w http.ResponseWriter, r *http.Request) {
@ -227,6 +233,7 @@ func handleAdminMailing(w http.ResponseWriter, r *http.Request) {
MailingBaseDN: config.MailingBaseDN,
MailingLists: EntryList(sr.Entries),
CanAdmin: login.CanAdmin,
LoggedIn: false,
}
sort.Sort(data.MailingLists)
@ -237,15 +244,14 @@ type AdminMailingListTplData struct {
Login *LoginStatus
MailingNameAttr string
MailingBaseDN string
MailingList *ldap.Entry
Members EntryList
PossibleNewMembers EntryList
AllowGuest bool
Error string
Success bool
CanAdmin bool
LoggedIn bool
}
func handleAdminMailingList(w http.ResponseWriter, r *http.Request) {
@ -430,6 +436,7 @@ func handleAdminMailingList(w http.ResponseWriter, r *http.Request) {
Error: dError,
Success: dSuccess,
CanAdmin: login.CanAdmin,
LoggedIn: true,
}
sort.Sort(data.Members)
sort.Sort(data.PossibleNewMembers)

View file

@ -11,6 +11,7 @@ type HomePageData struct {
BaseDN string
Org string
CanAdmin bool
LoggedIn bool
}
func handleHome(w http.ResponseWriter, r *http.Request) {
@ -26,6 +27,7 @@ func handleHome(w http.ResponseWriter, r *http.Request) {
BaseDN: config.BaseDN,
Org: config.Org,
CanAdmin: login.CanAdmin,
LoggedIn: true,
}
templateHome.Execute(w, data)

View file

@ -220,7 +220,7 @@ type LoginFormData struct {
WrongUser bool
WrongPass bool
ErrorMessage string
Login bool
LoggedIn bool
CanAdmin bool
}
@ -249,7 +249,7 @@ func handleLogin(w http.ResponseWriter, r *http.Request) *LoginInfo {
if err != nil {
data := &LoginFormData{
Username: username,
Login: false,
LoggedIn: false,
CanAdmin: false,
}
if ldap.IsErrorWithCode(err, ldap.LDAPResultInvalidCredentials) {

View file

@ -21,6 +21,7 @@ type ProfileTplData struct {
Description string
Login *LoginStatus
CanAdmin bool
LoggedIn bool
}
//ProfilePicture string
@ -33,7 +34,7 @@ type PasswdTplData struct {
NoMatchError bool
Success bool
CanAdmin bool
Login bool
LoggedIn bool
}
func handleProfile(w http.ResponseWriter, r *http.Request) {
@ -43,7 +44,7 @@ func handleProfile(w http.ResponseWriter, r *http.Request) {
if login == nil {
templatePasswd := getTemplate("passwd.html")
templatePasswd.Execute(w, PasswdTplData{
Login: false,
LoggedIn: false,
CanAdmin: false,
})
return
@ -55,6 +56,7 @@ func handleProfile(w http.ResponseWriter, r *http.Request) {
ErrorMessage: "",
Success: false,
CanAdmin: login.CanAdmin,
LoggedIn: true,
}
data.Mail = login.UserEntry.GetAttributeValue("mail")
@ -97,7 +99,7 @@ func handleProfile(w http.ResponseWriter, r *http.Request) {
data.Surname = findUser.SN
data.Description = findUser.Description
data.Mail = findUser.Mail
data.Login = nil
data.LoggedIn = false
/*
visible := strings.TrimSpace(strings.Join(r.Form["visibility"], ""))
@ -143,7 +145,7 @@ func handleFoundPassword(w http.ResponseWriter, r *http.Request) {
templateFoundPasswordPage := getTemplate("passwd.html")
data := PasswdTplData{
CanAdmin: false,
Login: false,
LoggedIn: false,
}
code := mux.Vars(r)["code"]
// code = strings.TrimSpace(strings.Join([]string{code}, ""))
@ -197,7 +199,7 @@ func handlePasswd(w http.ResponseWriter, r *http.Request) {
ErrorMessage: "",
Success: false,
CanAdmin: false,
Login: false,
LoggedIn: false,
}
login := checkLogin(w, r)

View file

@ -65,7 +65,7 @@
{{end}}
<li>&lt;&nbsp;<a href="#">Compte</a>
<ul class="submenu">
{{if .Login}}
{{if .LoggedIn}}
<a href="/logout">Se déconnecter</a>
<li><a href="/">Tableau de bord</a></li>
<li><a href="/profile">Modifier mon profil</a></li>