fix: oauth2 redirect url not consistent (#930)

* fix: oauth2 redirect url not consistent

* only use one redirect uri

* feat: allow to disable password authentication

* generate translation template

* update error

* redirect

* query
This commit is contained in:
UUBulb
2024-12-31 22:29:29 +08:00
committed by GitHub
parent 953fa153cc
commit 553f8e58d4
10 changed files with 272 additions and 212 deletions

View File

@@ -73,8 +73,18 @@ func updateProfile(c *gin.Context) (any, error) {
return nil, err
}
var bindCount int64
if err := singleton.DB.Where("user_id = ?", auth.(*model.User).ID).Count(&bindCount).Error; err != nil {
return nil, newGormError("%v", err)
}
if pf.RejectPassword && bindCount < 1 {
return nil, singleton.Localizer.ErrorT("you don't have any oauth2 bindings")
}
user.Username = pf.NewUsername
user.Password = string(hash)
user.RejectPassword = pf.RejectPassword
if err := singleton.DB.Save(&user).Error; err != nil {
return nil, newGormError("%v", err)
}