diff --git a/admin.go b/admin.go index 00a417c..edf0b3a 100644 --- a/admin.go +++ b/admin.go @@ -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) } diff --git a/home.go b/home.go index 4024f16..c0f3420 100644 --- a/home.go +++ b/home.go @@ -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) diff --git a/invite.go b/invite.go index 9f906b3..b2d3557 100644 --- a/invite.go +++ b/invite.go @@ -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) diff --git a/login.go b/login.go index 66dc827..e8ce93c 100644 --- a/login.go +++ b/login.go @@ -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 diff --git a/profile.go b/profile.go index 64dce10..7a4a4bb 100644 --- a/profile.go +++ b/profile.go @@ -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) }