Fixed Change Password Bug
This commit is contained in:
parent
60b204b82f
commit
900b75738f
5 changed files with 30 additions and 19 deletions
23
admin.go
23
admin.go
|
@ -44,6 +44,7 @@ type AdminUsersTplData struct {
|
||||||
UserBaseDN string
|
UserBaseDN string
|
||||||
Users EntryList
|
Users EntryList
|
||||||
CanAdmin bool
|
CanAdmin bool
|
||||||
|
LoggedIn bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleAdminActivateUsers(w http.ResponseWriter, r *http.Request) {
|
func handleAdminActivateUsers(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -76,6 +77,7 @@ func handleAdminActivateUsers(w http.ResponseWriter, r *http.Request) {
|
||||||
UserBaseDN: config.UserBaseDN,
|
UserBaseDN: config.UserBaseDN,
|
||||||
Users: EntryList(sr.Entries),
|
Users: EntryList(sr.Entries),
|
||||||
CanAdmin: login.CanAdmin,
|
CanAdmin: login.CanAdmin,
|
||||||
|
LoggedIn: bool,
|
||||||
}
|
}
|
||||||
templateAdminActivateUsers.Execute(w, data)
|
templateAdminActivateUsers.Execute(w, data)
|
||||||
|
|
||||||
|
@ -136,6 +138,7 @@ func handleAdminUsers(w http.ResponseWriter, r *http.Request) {
|
||||||
UserBaseDN: config.UserBaseDN,
|
UserBaseDN: config.UserBaseDN,
|
||||||
Users: EntryList(sr.Entries),
|
Users: EntryList(sr.Entries),
|
||||||
CanAdmin: login.CanAdmin,
|
CanAdmin: login.CanAdmin,
|
||||||
|
LoggedIn: false,
|
||||||
}
|
}
|
||||||
sort.Sort(data.Users)
|
sort.Sort(data.Users)
|
||||||
|
|
||||||
|
@ -157,6 +160,7 @@ type AdminGroupsTplData struct {
|
||||||
GroupBaseDN string
|
GroupBaseDN string
|
||||||
Groups EntryList
|
Groups EntryList
|
||||||
CanAdmin bool
|
CanAdmin bool
|
||||||
|
LoggedIn bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleAdminGroups(w http.ResponseWriter, r *http.Request) {
|
func handleAdminGroups(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -186,6 +190,7 @@ func handleAdminGroups(w http.ResponseWriter, r *http.Request) {
|
||||||
GroupBaseDN: config.GroupBaseDN,
|
GroupBaseDN: config.GroupBaseDN,
|
||||||
Groups: EntryList(sr.Entries),
|
Groups: EntryList(sr.Entries),
|
||||||
CanAdmin: login.CanAdmin,
|
CanAdmin: login.CanAdmin,
|
||||||
|
LoogedIn: false,
|
||||||
}
|
}
|
||||||
sort.Sort(data.Groups)
|
sort.Sort(data.Groups)
|
||||||
|
|
||||||
|
@ -198,6 +203,7 @@ type AdminMailingTplData struct {
|
||||||
MailingBaseDN string
|
MailingBaseDN string
|
||||||
MailingLists EntryList
|
MailingLists EntryList
|
||||||
CanAdmin bool
|
CanAdmin bool
|
||||||
|
LoggedIn bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleAdminMailing(w http.ResponseWriter, r *http.Request) {
|
func handleAdminMailing(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -227,6 +233,7 @@ func handleAdminMailing(w http.ResponseWriter, r *http.Request) {
|
||||||
MailingBaseDN: config.MailingBaseDN,
|
MailingBaseDN: config.MailingBaseDN,
|
||||||
MailingLists: EntryList(sr.Entries),
|
MailingLists: EntryList(sr.Entries),
|
||||||
CanAdmin: login.CanAdmin,
|
CanAdmin: login.CanAdmin,
|
||||||
|
LoggedIn: false,
|
||||||
}
|
}
|
||||||
sort.Sort(data.MailingLists)
|
sort.Sort(data.MailingLists)
|
||||||
|
|
||||||
|
@ -234,18 +241,17 @@ func handleAdminMailing(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type AdminMailingListTplData struct {
|
type AdminMailingListTplData struct {
|
||||||
Login *LoginStatus
|
Login *LoginStatus
|
||||||
MailingNameAttr string
|
MailingNameAttr string
|
||||||
MailingBaseDN string
|
MailingBaseDN string
|
||||||
|
|
||||||
MailingList *ldap.Entry
|
MailingList *ldap.Entry
|
||||||
Members EntryList
|
Members EntryList
|
||||||
PossibleNewMembers EntryList
|
PossibleNewMembers EntryList
|
||||||
AllowGuest bool
|
AllowGuest bool
|
||||||
|
Error string
|
||||||
Error string
|
Success bool
|
||||||
Success bool
|
CanAdmin bool
|
||||||
CanAdmin bool
|
LoggedIn bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleAdminMailingList(w http.ResponseWriter, r *http.Request) {
|
func handleAdminMailingList(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -430,6 +436,7 @@ func handleAdminMailingList(w http.ResponseWriter, r *http.Request) {
|
||||||
Error: dError,
|
Error: dError,
|
||||||
Success: dSuccess,
|
Success: dSuccess,
|
||||||
CanAdmin: login.CanAdmin,
|
CanAdmin: login.CanAdmin,
|
||||||
|
LoggedIn: true,
|
||||||
}
|
}
|
||||||
sort.Sort(data.Members)
|
sort.Sort(data.Members)
|
||||||
sort.Sort(data.PossibleNewMembers)
|
sort.Sort(data.PossibleNewMembers)
|
||||||
|
|
2
home.go
2
home.go
|
@ -11,6 +11,7 @@ type HomePageData struct {
|
||||||
BaseDN string
|
BaseDN string
|
||||||
Org string
|
Org string
|
||||||
CanAdmin bool
|
CanAdmin bool
|
||||||
|
LoggedIn bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleHome(w http.ResponseWriter, r *http.Request) {
|
func handleHome(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -26,6 +27,7 @@ func handleHome(w http.ResponseWriter, r *http.Request) {
|
||||||
BaseDN: config.BaseDN,
|
BaseDN: config.BaseDN,
|
||||||
Org: config.Org,
|
Org: config.Org,
|
||||||
CanAdmin: login.CanAdmin,
|
CanAdmin: login.CanAdmin,
|
||||||
|
LoggedIn: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
templateHome.Execute(w, data)
|
templateHome.Execute(w, data)
|
||||||
|
|
4
login.go
4
login.go
|
@ -220,7 +220,7 @@ type LoginFormData struct {
|
||||||
WrongUser bool
|
WrongUser bool
|
||||||
WrongPass bool
|
WrongPass bool
|
||||||
ErrorMessage string
|
ErrorMessage string
|
||||||
Login bool
|
LoggedIn bool
|
||||||
CanAdmin bool
|
CanAdmin bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ func handleLogin(w http.ResponseWriter, r *http.Request) *LoginInfo {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
data := &LoginFormData{
|
data := &LoginFormData{
|
||||||
Username: username,
|
Username: username,
|
||||||
Login: false,
|
LoggedIn: false,
|
||||||
CanAdmin: false,
|
CanAdmin: false,
|
||||||
}
|
}
|
||||||
if ldap.IsErrorWithCode(err, ldap.LDAPResultInvalidCredentials) {
|
if ldap.IsErrorWithCode(err, ldap.LDAPResultInvalidCredentials) {
|
||||||
|
|
12
profile.go
12
profile.go
|
@ -21,6 +21,7 @@ type ProfileTplData struct {
|
||||||
Description string
|
Description string
|
||||||
Login *LoginStatus
|
Login *LoginStatus
|
||||||
CanAdmin bool
|
CanAdmin bool
|
||||||
|
LoggedIn bool
|
||||||
}
|
}
|
||||||
|
|
||||||
//ProfilePicture string
|
//ProfilePicture string
|
||||||
|
@ -33,7 +34,7 @@ type PasswdTplData struct {
|
||||||
NoMatchError bool
|
NoMatchError bool
|
||||||
Success bool
|
Success bool
|
||||||
CanAdmin bool
|
CanAdmin bool
|
||||||
Login bool
|
LoggedIn bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleProfile(w http.ResponseWriter, r *http.Request) {
|
func handleProfile(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -43,7 +44,7 @@ func handleProfile(w http.ResponseWriter, r *http.Request) {
|
||||||
if login == nil {
|
if login == nil {
|
||||||
templatePasswd := getTemplate("passwd.html")
|
templatePasswd := getTemplate("passwd.html")
|
||||||
templatePasswd.Execute(w, PasswdTplData{
|
templatePasswd.Execute(w, PasswdTplData{
|
||||||
Login: false,
|
LoggedIn: false,
|
||||||
CanAdmin: false,
|
CanAdmin: false,
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
|
@ -55,6 +56,7 @@ func handleProfile(w http.ResponseWriter, r *http.Request) {
|
||||||
ErrorMessage: "",
|
ErrorMessage: "",
|
||||||
Success: false,
|
Success: false,
|
||||||
CanAdmin: login.CanAdmin,
|
CanAdmin: login.CanAdmin,
|
||||||
|
LoggedIn: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
data.Mail = login.UserEntry.GetAttributeValue("mail")
|
data.Mail = login.UserEntry.GetAttributeValue("mail")
|
||||||
|
@ -97,7 +99,7 @@ func handleProfile(w http.ResponseWriter, r *http.Request) {
|
||||||
data.Surname = findUser.SN
|
data.Surname = findUser.SN
|
||||||
data.Description = findUser.Description
|
data.Description = findUser.Description
|
||||||
data.Mail = findUser.Mail
|
data.Mail = findUser.Mail
|
||||||
data.Login = nil
|
data.LoggedIn = false
|
||||||
|
|
||||||
/*
|
/*
|
||||||
visible := strings.TrimSpace(strings.Join(r.Form["visibility"], ""))
|
visible := strings.TrimSpace(strings.Join(r.Form["visibility"], ""))
|
||||||
|
@ -143,7 +145,7 @@ func handleFoundPassword(w http.ResponseWriter, r *http.Request) {
|
||||||
templateFoundPasswordPage := getTemplate("passwd.html")
|
templateFoundPasswordPage := getTemplate("passwd.html")
|
||||||
data := PasswdTplData{
|
data := PasswdTplData{
|
||||||
CanAdmin: false,
|
CanAdmin: false,
|
||||||
Login: false,
|
LoggedIn: false,
|
||||||
}
|
}
|
||||||
code := mux.Vars(r)["code"]
|
code := mux.Vars(r)["code"]
|
||||||
// code = strings.TrimSpace(strings.Join([]string{code}, ""))
|
// code = strings.TrimSpace(strings.Join([]string{code}, ""))
|
||||||
|
@ -197,7 +199,7 @@ func handlePasswd(w http.ResponseWriter, r *http.Request) {
|
||||||
ErrorMessage: "",
|
ErrorMessage: "",
|
||||||
Success: false,
|
Success: false,
|
||||||
CanAdmin: false,
|
CanAdmin: false,
|
||||||
Login: false,
|
LoggedIn: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
login := checkLogin(w, r)
|
login := checkLogin(w, r)
|
||||||
|
|
|
@ -65,15 +65,15 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
<li>< <a href="#">Compte</a>
|
<li>< <a href="#">Compte</a>
|
||||||
<ul class="submenu">
|
<ul class="submenu">
|
||||||
{{if .Login}}
|
{{if .LoggedIn}}
|
||||||
<a href="/logout">Se déconnecter</a>
|
<a href="/logout">Se déconnecter</a>
|
||||||
<li><a href="/">Tableau de bord</a></li>
|
<li><a href="/">Tableau de bord</a></li>
|
||||||
<li><a href="/profile">Modifier mon profil</a></li>
|
<li><a href="/profile">Modifier mon profil</a></li>
|
||||||
<li><a href="/passwd">Modifier mon mot de passe</a></li>
|
<li><a href="/passwd">Modifier mon mot de passe</a></li>
|
||||||
{{else}}
|
{{else}}
|
||||||
<li><a href="/">Se connecter</a></li>
|
<li><a href="/">Se connecter</a></li>
|
||||||
<li><a href="/gpas">Mal de passe oublié</a></li>
|
<li><a href="/gpas">Mal de passe oublié</a></li>
|
||||||
<li><a href="/invite/new_account">S'enregistrer</a></li>
|
<li><a href="/invite/new_account">S'enregistrer</a></li>
|
||||||
{{end}}
|
{{end}}
|
||||||
</ul></li>
|
</ul></li>
|
||||||
<li> < <a href="#" class="jour-nuit" id="jour-nuit">Jour et nuit</a></li>
|
<li> < <a href="#" class="jour-nuit" id="jour-nuit">Jour et nuit</a></li>
|
||||||
|
|
Loading…
Reference in a new issue