🐛修复可重复创建相同账号的bug
Some checks failed
continuous-integration/drone/tag Build is failing

This commit is contained in:
coward 2024-09-04 10:06:29 +08:00
parent a12552a608
commit 72420f2ede

View File

@ -39,6 +39,11 @@ func (s user) CreateUser(user *model.User) (err error) {
return s.Model(&model.User{}).Where("id = ?", user.Id).Updates(&updates).Error
}
// 判断账号是否已经存在
if _, err = s.GetUserByAccount(user.Account); err == nil {
return errors.New("账号已经存在,请勿重复创建!")
}
defaultPassword := utils.Password().GenerateHashPassword("admin123")
if user.Password == "" { // 没有密码给一个默认密码
user.Password = defaultPassword