Fixed Change Password Bug
This commit is contained in:
parent
020dc0f6d4
commit
6033c90d96
1 changed files with 113 additions and 125 deletions
32
session.go
32
session.go
|
@ -10,7 +10,10 @@ import (
|
|||
|
||||
func checkLogin(w http.ResponseWriter, r *http.Request) *LoginStatus {
|
||||
var login_info *LoginInfo
|
||||
|
||||
l, err := ldapOpen(w)
|
||||
if l == nil {
|
||||
return nil
|
||||
}
|
||||
session, err := store.Get(r, SESSION_NAME)
|
||||
if err == nil {
|
||||
username, ok := session.Values["login_username"]
|
||||
|
@ -23,28 +26,16 @@ func checkLogin(w http.ResponseWriter, r *http.Request) *LoginStatus {
|
|||
Username: username.(string),
|
||||
Password: password.(string),
|
||||
}
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
l, err := ldapOpen(w)
|
||||
if l == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
log.Printf("checkLogin ldapOpen : %v", err)
|
||||
log.Printf("checkLogin ldapOpen : %v", session)
|
||||
log.Printf("checkLogin ldapOpen : %v", session.Values)
|
||||
return nil
|
||||
}
|
||||
|
||||
err = bind(User{
|
||||
DN: login_info.DN,
|
||||
Password: login_info.Password,
|
||||
}, config, l)
|
||||
|
||||
if err != nil {
|
||||
delete(session.Values, "login_username")
|
||||
delete(session.Values, "login_password")
|
||||
|
@ -57,19 +48,17 @@ func checkLogin(w http.ResponseWriter, r *http.Request) *LoginStatus {
|
|||
}
|
||||
return checkLogin(w, r)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
ldapUser, err := get(User{
|
||||
DN: login_info.DN,
|
||||
CN: login_info.Username,
|
||||
}, config, l)
|
||||
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return nil
|
||||
}
|
||||
|
||||
userEntry := ldapUser.UserEntry
|
||||
|
||||
loginStatus := &LoginStatus{
|
||||
Info: login_info,
|
||||
conn: l,
|
||||
|
@ -77,8 +66,10 @@ func checkLogin(w http.ResponseWriter, r *http.Request) *LoginStatus {
|
|||
CanAdmin: ldapUser.CanAdmin,
|
||||
CanInvite: ldapUser.CanInvite,
|
||||
}
|
||||
return loginStatus
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
|
||||
requestKind := "(objectClass=organizationalPerson)"
|
||||
if strings.EqualFold(login_info.DN, config.AdminAccount) {
|
||||
|
@ -163,10 +154,7 @@ func checkLogin(w http.ResponseWriter, r *http.Request) *LoginStatus {
|
|||
// }
|
||||
|
||||
return loginStatus
|
||||
*/
|
||||
|
||||
return loginStatus
|
||||
}
|
||||
*/
|
||||
|
||||
func logout(w http.ResponseWriter, r *http.Request) error {
|
||||
session, err := store.Get(r, SESSION_NAME)
|
||||
|
|
Loading…
Reference in a new issue