From 900b75738fe371e9e9cb97f25c4580f761397775 Mon Sep 17 00:00:00 2001 From: Chris Mann Date: Mon, 24 Jul 2023 16:28:22 +0200 Subject: [PATCH] Fixed Change Password Bug --- admin.go | 23 +++++++++++++++-------- home.go | 2 ++ login.go | 4 ++-- profile.go | 12 +++++++----- templates/layout.html | 8 ++++---- 5 files changed, 30 insertions(+), 19 deletions(-) diff --git a/admin.go b/admin.go index edf0b3a..a1b8d16 100644 --- a/admin.go +++ b/admin.go @@ -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) @@ -234,18 +241,17 @@ func handleAdminMailing(w http.ResponseWriter, r *http.Request) { } type AdminMailingListTplData struct { - Login *LoginStatus - MailingNameAttr string - MailingBaseDN string - + Login *LoginStatus + MailingNameAttr string + MailingBaseDN string MailingList *ldap.Entry Members EntryList PossibleNewMembers EntryList AllowGuest bool - - Error string - Success bool - CanAdmin 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) diff --git a/home.go b/home.go index c0f3420..3d3152e 100644 --- a/home.go +++ b/home.go @@ -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) diff --git a/login.go b/login.go index e8ce93c..bee97e3 100644 --- a/login.go +++ b/login.go @@ -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) { diff --git a/profile.go b/profile.go index 3cc5621..032a5fb 100644 --- a/profile.go +++ b/profile.go @@ -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) diff --git a/templates/layout.html b/templates/layout.html index e7c0366..d22b306 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -65,15 +65,15 @@ {{end}}
  • Compte
  •  < Jour et nuit