fix
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/chinese_to_pinyin"
|
||||
"fusenapi/utils/email"
|
||||
"fusenapi/utils/encryption_decryption"
|
||||
"gorm.io/gorm"
|
||||
"net/http"
|
||||
"strings"
|
||||
@@ -73,10 +72,6 @@ func (l *CreateLdapUserLogic) CreateLdapUser(req *types.CreateLdapUserReq, r *ht
|
||||
if err := tx.WithContext(l.ctx).Model(&gmodel.LdapUser{}).Create(userData).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
pwd, err := encryption_decryption.CBCEncrypt(req.Password)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return l.svcCtx.Ldap.Create(userDN, map[string][]string{
|
||||
"objectClass": {"person", "organizationalPerson", "inetOrgPerson", "posixAccount", "top", "shadowAccount"}, //固有属性
|
||||
"shadowLastChange": {"19676"}, //固有属性
|
||||
@@ -96,7 +91,7 @@ func (l *CreateLdapUserLogic) CreateLdapUser(req *types.CreateLdapUserReq, r *ht
|
||||
"departmentNumber": {fmt.Sprintf("%d", req.GroupId)}, //权限分组id
|
||||
"postalAddress": {req.Avatar}, //头像
|
||||
"mobile": {req.Mobile}, //手机号
|
||||
"userPassword": {"{crypt}" + pwd}, //密码
|
||||
"userPassword": {req.Password}, //密码
|
||||
})
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -3,7 +3,6 @@ package logic
|
||||
import (
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/email"
|
||||
"fusenapi/utils/encryption_decryption"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
@@ -57,26 +56,11 @@ func (l *UpdateLdapUserPwdLogic) UpdateLdapUserPwd(req *types.UpdateLdapUserPwdR
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, err.Error())
|
||||
}
|
||||
if len(user.Password) > 7 && user.Password[:7] == "{crypt}" {
|
||||
//解密旧的密码
|
||||
oldPwd, err := encryption_decryption.CBCDecrypt(user.Password[7:])
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "解密旧的密码出错")
|
||||
}
|
||||
//验证旧的密码
|
||||
if oldPwd != req.OldPassword {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "旧密码不对,请重新尝试")
|
||||
}
|
||||
}
|
||||
//加密新的密码
|
||||
newPwd, err := encryption_decryption.CBCEncrypt(req.NewPassword)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "加密密码失败")
|
||||
if user.Password != req.OldPassword {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "旧密码不对,请重新尝试")
|
||||
}
|
||||
err = l.svcCtx.Ldap.Update(req.UserDN, map[string][]string{
|
||||
"userPassword": {"{crypt}" + newPwd},
|
||||
"userPassword": {req.NewPassword},
|
||||
})
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
|
||||
Reference in New Issue
Block a user