Implementing Activate User

This commit is contained in:
Chris Mann 2023-07-21 09:51:57 +02:00
parent 4dda9c91cb
commit 54e68b9fe3
2 changed files with 14 additions and 12 deletions

View file

@ -38,12 +38,15 @@ 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)
// login := checkInviterLogin(w, r)
// if login == nil {
// return
// }
l, _ := ldap.DialURL(config.LdapServerAddr)
l.Bind(config.NewUserDN, config.NewUserPassword)
// l, _ := ldap.DialURL(config.LdapServerAddr)
// l.Bind(config.NewUserDN, config.NewUserPassword)
handleNewAccount(w, r, l, config.NewUserDN)
}
@ -143,7 +146,7 @@ func handleNewAccount(w http.ResponseWriter, r *http.Request, l *ldap.Conn, invi
data.ErrorPasswordMismatch = true
} else {
newUser.Password = password2
data.Success = addNewUser(newUser, config)
data.Success = addNewUser(newUser, config, l)
http.Redirect(w, r, "/admin/ldap/"+newUser.DN, http.StatusFound)
}

View file

@ -1,7 +1,6 @@
package main
import (
"crypto/tls"
"fmt"
"log"
@ -41,14 +40,14 @@ func suggestPassword() string {
return password
}
func addNewUser(newUser NewUser, config *ConfigFile) bool {
func addNewUser(newUser NewUser, config *ConfigFile, ldapConn *ldap.Conn) bool {
log.Printf(fmt.Sprint("Adding New User"))
l, _ := ldap.DialURL(config.LdapServerAddr)
err := l.StartTLS(&tls.Config{InsecureSkipVerify: true})
if err != nil {
log.Printf(fmt.Sprintf("86: %v", err))
}
l.Bind(config.NewUserDN, config.NewUserPassword)
// l, _ := ldap.DialURL(config.LdapServerAddr)
// l.Bind(config.NewUserDN, config.NewUserPassword)
// err := l.StartTLS(&tls.Config{InsecureSkipVerify: true})
// if err != nil {
// log.Printf(fmt.Sprintf("86: %v", err))
// }
// l.Bind(config.)
dn := newUser.DN
@ -82,7 +81,7 @@ func addNewUser(newUser NewUser, config *ConfigFile) bool {
// conn :=
err = l.Add(req)
err := ldapConn.Add(req)
log.Printf(fmt.Sprintf("71: %v", err))
log.Printf(fmt.Sprintf("72: %v", req))
log.Printf(fmt.Sprintf("73: %v", newUser))