Implementing Activate User

This commit is contained in:
Chris Mann 2023-07-21 13:50:34 +02:00
parent 98529b19f4
commit 516365c6a2
2 changed files with 9 additions and 8 deletions

View file

@ -39,8 +39,8 @@ func checkInviterLogin(w http.ResponseWriter, r *http.Request) *LoginStatus {
// New account creation directly from interface
func handleInviteNewAccount(w http.ResponseWriter, r *http.Request) {
// l := ldapOpen(w)
// l.Bind(config.NewUserDN, config.NewUserPassword)
l := ldapOpen(w)
l.Bind(config.NewUserDN, config.NewUserPassword)
// login := checkInviterLogin(w, r)
// if login == nil {
@ -49,12 +49,13 @@ func handleInviteNewAccount(w http.ResponseWriter, r *http.Request) {
// l, _ := ldap.DialURL(config.LdapServerAddr)
// 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 {
log.Printf(fmt.Sprintf("58: %v %v", err, loginInfo))
}
l := ldapOpen(w)
// l := ldapOpen(w)
if l == nil {
return
}

View file

@ -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)
// if l == 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)
if err != nil {
return err, nil
return nil, err
}
// 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)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return err, nil
return nil, err
}
LoginInfo := LoginInfo{
@ -268,6 +268,6 @@ func doLogin(w http.ResponseWriter, r *http.Request, username string, user_dn st
Password: password,
}
return nil, &LoginInfo
return &LoginInfo, nil
}