diff --git a/invite.go b/invite.go index aa9e00b..867a8e7 100644 --- a/invite.go +++ b/invite.go @@ -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 } diff --git a/login.go b/login.go index 1e497ce..c2fedb3 100644 --- a/login.go +++ b/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) // 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 }