Implementing Activate User
This commit is contained in:
parent
8a5539a143
commit
7c9faf93bb
1 changed files with 9 additions and 9 deletions
18
login.go
18
login.go
|
@ -213,8 +213,8 @@ func handleLogin(w http.ResponseWriter, r *http.Request) *LoginInfo {
|
||||||
if strings.EqualFold(username, config.AdminAccount) {
|
if strings.EqualFold(username, config.AdminAccount) {
|
||||||
user_dn = username
|
user_dn = username
|
||||||
}
|
}
|
||||||
loginInfo := doLogin(w, r, username, user_dn, password)
|
_, loginInfo := doLogin(w, r, username, user_dn, password)
|
||||||
return &loginInfo
|
return loginInfo
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
http.Error(w, "Unsupported method", http.StatusBadRequest)
|
http.Error(w, "Unsupported method", http.StatusBadRequest)
|
||||||
|
@ -222,11 +222,11 @@ func handleLogin(w http.ResponseWriter, r *http.Request) *LoginInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func doLogin(w http.ResponseWriter, r *http.Request, username string, user_dn string, password string) LoginInfo {
|
func doLogin(w http.ResponseWriter, r *http.Request, username string, user_dn string, password string) (error, *LoginInfo) {
|
||||||
l := ldapOpen(w)
|
l := ldapOpen(w)
|
||||||
if l == nil {
|
// if l == nil {
|
||||||
return nil
|
// return nil, nil
|
||||||
}
|
// }
|
||||||
|
|
||||||
err := l.Bind(user_dn, password)
|
err := l.Bind(user_dn, password)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
@ -242,7 +242,7 @@ func doLogin(w http.ResponseWriter, r *http.Request, username string, user_dn st
|
||||||
data.ErrorMessage = err.Error()
|
data.ErrorMessage = err.Error()
|
||||||
}
|
}
|
||||||
templateLogin.Execute(w, data)
|
templateLogin.Execute(w, data)
|
||||||
return nil
|
return err, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Successfully logged in, save it to session
|
// Successfully logged in, save it to session
|
||||||
|
@ -258,10 +258,10 @@ func doLogin(w http.ResponseWriter, r *http.Request, username string, user_dn st
|
||||||
err = session.Save(r, w)
|
err = session.Save(r, w)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return nil
|
return err, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return LoginInfo{
|
return nil, &LoginInfo{
|
||||||
DN: user_dn,
|
DN: user_dn,
|
||||||
Username: username,
|
Username: username,
|
||||||
Password: password,
|
Password: password,
|
||||||
|
|
Loading…
Reference in a new issue