fix new users could not be automatically created when signing in via oauth 2.0

This commit is contained in:
MaysWind
2025-10-21 23:59:18 +08:00
parent 46e275d843
commit a42c5fa988
4 changed files with 11 additions and 8 deletions
+7 -3
View File
@@ -184,7 +184,7 @@ func (s *UserService) GetUserAvatar(c core.Context, uid int64, fileExtension str
}
// CreateUser saves a new user model to database
func (s *UserService) CreateUser(c core.Context, user *models.User) error {
func (s *UserService) CreateUser(c core.Context, user *models.User, noPassword bool) error {
exists, err := s.ExistsUsername(c, user.Username)
if err != nil {
@@ -201,7 +201,7 @@ func (s *UserService) CreateUser(c core.Context, user *models.User) error {
return errs.ErrUserEmailAlreadyExists
}
if user.Password == "" {
if !noPassword && user.Password == "" {
return errs.ErrPasswordIsEmpty
}
@@ -215,7 +215,11 @@ func (s *UserService) CreateUser(c core.Context, user *models.User) error {
return errs.ErrSystemIsBusy
}
user.Password = utils.EncodePassword(user.Password, user.Salt)
if !noPassword {
user.Password = utils.EncodePassword(user.Password, user.Salt)
} else {
user.Password = ""
}
user.Deleted = false