Factoring the model user and correcting password
This commit is contained in:
parent
7fca2fa4ae
commit
890604b943
2 changed files with 11 additions and 1 deletions
8
login.go
8
login.go
|
@ -68,7 +68,13 @@ func checkLogin(w http.ResponseWriter, r *http.Request) *LoginStatus {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
err = l.Bind(login_info.DN, login_info.Password)
|
err = bind(User{
|
||||||
|
DN: login_info.DN,
|
||||||
|
Password: login_info.Password,
|
||||||
|
}, config, l)
|
||||||
|
|
||||||
|
// err = l.Bind(login_info.DN, login_info.Password)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
delete(session.Values, "login_username")
|
delete(session.Values, "login_username")
|
||||||
delete(session.Values, "login_password")
|
delete(session.Values, "login_password")
|
||||||
|
|
|
@ -98,6 +98,10 @@ func passwd(user User, config *ConfigFile, ldapConn *ldap.Conn) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func bind(user User, config *ConfigFile, ldapConn *ldap.Conn) error {
|
||||||
|
return ldapConn.Bind(user.DN, user.Password)
|
||||||
|
}
|
||||||
|
|
||||||
func replaceIfContent(modifReq *ldap.ModifyRequest, key string, value string) error {
|
func replaceIfContent(modifReq *ldap.ModifyRequest, key string, value string) error {
|
||||||
if value != "" {
|
if value != "" {
|
||||||
modifReq.Replace(key, []string{value})
|
modifReq.Replace(key, []string{value})
|
||||||
|
|
Loading…
Reference in a new issue