Working on signup workfow

This commit is contained in:
Chris Mann 2023-07-26 14:15:46 +02:00
parent 385fd0b588
commit b55fcc0968
2 changed files with 12 additions and 17 deletions

View file

@ -71,7 +71,7 @@ func passwordLost(user User, config *ConfigFile, ldapConn *ldap.Conn) error {
user.Mail = searchRes.Entries[0].GetAttributeValue("mail")
user.OtherMailbox = searchRes.Entries[0].GetAttributeValue("carLicense")
/* Check for outstanding invitation */
searchReq = ldap.NewSearchRequest(config.InvitationBaseDN, ldap.ScopeBaseObject,
searchReq = ldap.NewSearchRequest(user.DN, ldap.ScopeBaseObject,
ldap.NeverDerefAliases, 0, 0, false, "(uid="+user.UID+")", []string{"seeAlso"}, nil)
searchRes, err = ldapConn.Search(searchReq)
if err != nil {
@ -94,7 +94,7 @@ func passwordLost(user User, config *ConfigFile, ldapConn *ldap.Conn) error {
log.Printf("passwordLost 84 : %v", user)
// // log.Printf("passwordLost 85 : %v", searchRes.Entries[0]))
// // For some reason I get here even if the entry exists already
// return err
return err
}
}
ldapNewConn, err := openNewUserLdap(config)
@ -104,8 +104,8 @@ func passwordLost(user User, config *ConfigFile, ldapConn *ldap.Conn) error {
err = passwd(user, config, ldapNewConn)
if err != nil {
log.Printf("passwordLost passwd : %v", err)
log.Printf("passwordLost 91 : %v", user)
log.Printf("passwordLost 92 : %v", searchRes.Entries[0])
log.Printf("passwordLost passwd : %v", user)
log.Printf("passwordLost passwd : %v", searchRes.Entries[0])
return err
}
templateMail := template.Must(template.ParseFiles(templatePath + "/passwd/lost_password_email.txt"))
@ -132,7 +132,7 @@ func passwordLost(user User, config *ConfigFile, ldapConn *ldap.Conn) error {
return err
}
log.Printf("Mail sent.")
return nil
return err
}
func passwordFound(user User, config *ConfigFile, ldapConn *ldap.Conn) (string, error) {

View file

@ -64,9 +64,10 @@ func get(user User, config *ConfigFile, ldapConn *ldap.Conn) (*User, error) {
return &resUser, nil
}
// Adds a new user
func add(user User, config *ConfigFile, ldapConn *ldap.Conn) error {
log.Printf(fmt.Sprint("Adding New User"))
// LDAP Add Object
dn := user.DN
req := ldap.NewAddRequest(dn, nil)
req.Attribute("objectClass", []string{"top", "person", "organizationalPerson", "inetOrgPerson"})
@ -94,17 +95,7 @@ func add(user User, config *ConfigFile, ldapConn *ldap.Conn) error {
if user.Description != "" {
req.Attribute("description", []string{user.Description})
}
// if user.Password != "" {
// pwdEncoded, _ := encodePassword(user.Password)
// // if err != nil {
// // log.Printf("Error encoding password: %s", err)
// // return err
// // }
// req.Attribute("userPassword", []string{pwdEncoded})
// }
// conn :=
// Add the User
err := ldapConn.Add(req)
if err != nil {
log.Printf(fmt.Sprintf("add(User) ldapconn.Add: %v", err))
@ -122,6 +113,10 @@ func add(user User, config *ConfigFile, ldapConn *ldap.Conn) error {
newUserLdapConn, _ := openNewUserLdap(config)
err = passwordLost(user, config, newUserLdapConn)
if err != nil {
log.Printf("add User PasswordLost %v", err)
log.Printf("add User PasswordLost %v", newUserLdapConn)
}
// sendMailTplData := SendMailTplData{
// From: "alice@resdigita.org",