Implementing Activate User
This commit is contained in:
parent
98529b19f4
commit
516365c6a2
2 changed files with 9 additions and 8 deletions
|
@ -39,8 +39,8 @@ func checkInviterLogin(w http.ResponseWriter, r *http.Request) *LoginStatus {
|
||||||
// New account creation directly from interface
|
// New account creation directly from interface
|
||||||
|
|
||||||
func handleInviteNewAccount(w http.ResponseWriter, r *http.Request) {
|
func handleInviteNewAccount(w http.ResponseWriter, r *http.Request) {
|
||||||
// l := ldapOpen(w)
|
l := ldapOpen(w)
|
||||||
// l.Bind(config.NewUserDN, config.NewUserPassword)
|
l.Bind(config.NewUserDN, config.NewUserPassword)
|
||||||
|
|
||||||
// login := checkInviterLogin(w, r)
|
// login := checkInviterLogin(w, r)
|
||||||
// if login == nil {
|
// if login == nil {
|
||||||
|
@ -49,12 +49,13 @@ func handleInviteNewAccount(w http.ResponseWriter, r *http.Request) {
|
||||||
// l, _ := ldap.DialURL(config.LdapServerAddr)
|
// l, _ := ldap.DialURL(config.LdapServerAddr)
|
||||||
// l.Bind(config.NewUserDN, config.NewUserPassword)
|
// l.Bind(config.NewUserDN, config.NewUserPassword)
|
||||||
|
|
||||||
err, loginInfo := doLogin(w, r, "testuser", config.NewUserDN, config.NewUserPassword)
|
loginInfo, err := doLogin(w, r, "testuser", config.NewUserDN, config.NewUserPassword)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf(fmt.Sprintf("58: %v %v", err, loginInfo))
|
log.Printf(fmt.Sprintf("58: %v %v", err, loginInfo))
|
||||||
}
|
}
|
||||||
|
|
||||||
l := ldapOpen(w)
|
// l := ldapOpen(w)
|
||||||
if l == nil {
|
if l == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
8
login.go
8
login.go
|
@ -235,7 +235,7 @@ func handleLogin(w http.ResponseWriter, r *http.Request) *LoginInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func doLogin(w http.ResponseWriter, r *http.Request, username string, user_dn string, password string) (error, *LoginInfo) {
|
func doLogin(w http.ResponseWriter, r *http.Request, username string, user_dn string, password string) (*LoginInfo, error) {
|
||||||
l := ldapOpen(w)
|
l := ldapOpen(w)
|
||||||
// if l == nil {
|
// if l == nil {
|
||||||
// return nil, nil
|
// return nil, nil
|
||||||
|
@ -243,7 +243,7 @@ func doLogin(w http.ResponseWriter, r *http.Request, username string, user_dn st
|
||||||
|
|
||||||
err := l.Bind(user_dn, password)
|
err := l.Bind(user_dn, password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err, nil
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Successfully logged in, save it to session
|
// Successfully logged in, save it to session
|
||||||
|
@ -259,7 +259,7 @@ 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 err, nil
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
LoginInfo := LoginInfo{
|
LoginInfo := LoginInfo{
|
||||||
|
@ -268,6 +268,6 @@ func doLogin(w http.ResponseWriter, r *http.Request, username string, user_dn st
|
||||||
Password: password,
|
Password: password,
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, &LoginInfo
|
return &LoginInfo, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue