This commit is contained in:
laodaming 2023-11-21 10:38:11 +08:00
parent f946f2926a
commit 06b826769b
3 changed files with 13 additions and 11 deletions

View File

@ -55,15 +55,17 @@ func (l *UpdateLdapUserPwdLogic) UpdateLdapUserPwd(req *types.UpdateLdapUserPwdR
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeServiceErr, err.Error())
}
//解密旧的密码
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, "旧密码不对,请重新尝试")
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)

View File

@ -166,7 +166,7 @@ type GetLdapUserInfoReq struct {
}
type GetLdapUserInfoRsp struct {
UserId int64 `json:"userId"`
UserId int64 `json:"user_id"`
UserDN string `json:"user_dn"`
UserName string `json:"user_name"` //用户名
Email string `json:"email"` //邮箱

View File

@ -249,7 +249,7 @@ type GetLdapUserInfoReq {
UserDN string `form:"user_dn"` //用户dn
}
type GetLdapUserInfoRsp {
UserId int64 `json:"userId"`
UserId int64 `json:"user_id"`
UserDN string `json:"user_dn"`
UserName string `json:"user_name"` //用户名
Email string `json:"email"` //邮箱