fix: 已离职的账号或者未同步的账号,不能重置密码 (#167)

This commit is contained in:
二丫讲梵 2023-03-10 10:07:53 +08:00 committed by GitHub
parent 8c05e7df57
commit 499a7133c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 4 deletions

View File

@ -23,11 +23,15 @@ func (l BaseLogic) SendCode(c *gin.Context, req interface{}) (data interface{},
} }
_ = c _ = c
// 判断邮箱是否正确 // 判断邮箱是否正确
if !isql.User.Exist(tools.H{"mail": r.Mail}) { user := new(model.User)
return nil, tools.NewValidatorError(fmt.Errorf("邮箱不存在,请检查邮箱是否正确")) err := isql.User.Find(tools.H{"mail": r.Mail}, user)
if err != nil {
return nil, tools.NewMySqlError(fmt.Errorf("通过邮箱查询用户失败" + err.Error()))
} }
if user.Status != 1 || user.SyncState != 1 {
err := tools.SendCode([]string{r.Mail}) return nil, tools.NewMySqlError(fmt.Errorf("该用户已离职或者未同步在ldap无法重置密码如有疑问请联系管理员"))
}
err = tools.SendCode([]string{r.Mail})
if err != nil { if err != nil {
return nil, tools.NewLdapError(fmt.Errorf("邮件发送失败" + err.Error())) return nil, tools.NewLdapError(fmt.Errorf("邮件发送失败" + err.Error()))
} }