Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions logic/base_logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ func (l BaseLogic) SendCode(c *gin.Context, req interface{}) (data interface{},
}
_ = c
// 判断邮箱是否正确
if !isql.User.Exist(tools.H{"mail": r.Mail}) {
return nil, tools.NewValidatorError(fmt.Errorf("邮箱不存在,请检查邮箱是否正确"))
user := new(model.User)
err := isql.User.Find(tools.H{"mail": r.Mail}, user)
if err != nil {
return nil, tools.NewMySqlError(fmt.Errorf("通过邮箱查询用户失败" + err.Error()))
}

err := tools.SendCode([]string{r.Mail})
if user.Status != 1 || user.SyncState != 1 {
return nil, tools.NewMySqlError(fmt.Errorf("该用户已离职或者未同步在ldap,无法重置密码,如有疑问,请联系管理员"))
}
err = tools.SendCode([]string{r.Mail})
if err != nil {
return nil, tools.NewLdapError(fmt.Errorf("邮件发送失败" + err.Error()))
}
Expand Down