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

View file

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