Refactoring
This commit is contained in:
parent
9b04e88b72
commit
75f4a17c3f
2 changed files with 13 additions and 12 deletions
|
@ -39,17 +39,18 @@ func get(user User, config *ConfigFile, ldapConn *ldap.Conn) (*User, error) {
|
||||||
}
|
}
|
||||||
userEntry := searchRes.Entries[0]
|
userEntry := searchRes.Entries[0]
|
||||||
resUser := User{
|
resUser := User{
|
||||||
DN: user.DN,
|
DN: user.DN,
|
||||||
GivenName: searchRes.Entries[0].GetAttributeValue("givenName"),
|
GivenName: searchRes.Entries[0].GetAttributeValue("givenName"),
|
||||||
DisplayName: searchRes.Entries[0].GetAttributeValue("displayName"),
|
DisplayName: searchRes.Entries[0].GetAttributeValue("displayName"),
|
||||||
Description: searchRes.Entries[0].GetAttributeValue("description"),
|
Description: searchRes.Entries[0].GetAttributeValue("description"),
|
||||||
SN: searchRes.Entries[0].GetAttributeValue("sn"),
|
SN: searchRes.Entries[0].GetAttributeValue("sn"),
|
||||||
UID: searchRes.Entries[0].GetAttributeValue("uid"),
|
UID: searchRes.Entries[0].GetAttributeValue("uid"),
|
||||||
CN: searchRes.Entries[0].GetAttributeValue("cn"),
|
CN: searchRes.Entries[0].GetAttributeValue("cn"),
|
||||||
Mail: searchRes.Entries[0].GetAttributeValue("mail"),
|
Mail: searchRes.Entries[0].GetAttributeValue("mail"),
|
||||||
CanAdmin: strings.EqualFold(user.DN, config.AdminAccount),
|
OtherMailbox: searchRes.Entries[0].GetAttributeValue("carLicense"),
|
||||||
CanInvite: true,
|
CanAdmin: strings.EqualFold(user.DN, config.AdminAccount),
|
||||||
UserEntry: userEntry,
|
CanInvite: true,
|
||||||
|
UserEntry: userEntry,
|
||||||
}
|
}
|
||||||
searchReq.BaseDN = config.GroupCanAdmin
|
searchReq.BaseDN = config.GroupCanAdmin
|
||||||
searchReq.Filter = "(member=" + user.DN + ")"
|
searchReq.Filter = "(member=" + user.DN + ")"
|
||||||
|
|
2
utils.go
2
utils.go
|
@ -61,7 +61,7 @@ func sendMail(sendMailTplData SendMailTplData) error {
|
||||||
message := buf.Bytes()
|
message := buf.Bytes()
|
||||||
auth := smtp.PlainAuth("", config.SMTPUsername, config.SMTPPassword, config.SMTPServer)
|
auth := smtp.PlainAuth("", config.SMTPUsername, config.SMTPPassword, config.SMTPServer)
|
||||||
log.Printf("auth: %v", auth)
|
log.Printf("auth: %v", auth)
|
||||||
err = smtp.SendMail(config.SMTPServer+":587", auth, config.SMTPUsername, []string{user.OtherMailbox}, message)
|
err = smtp.SendMail(config.SMTPServer+":587", auth, config.SMTPUsername, []string{sendMailTplData.To}, message)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("email send error %v", err)
|
log.Printf("email send error %v", err)
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in a new issue