Skip to content

Commit

Permalink
fix(models): resolve a bug with UpdateOAuth query
Browse files Browse the repository at this point in the history
  • Loading branch information
vednoc committed May 29, 2021
1 parent b39ae38 commit e024042
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion handlers/oauthProvider/oauth_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func OAuthSettingsPost(c *fiber.Ctx) error {

var err error
if id != "" {
err = models.UpdateOAuth(database.DB, &q)
err = models.UpdateOAuth(database.DB, &q, id)
} else {
q.ClientID = utils.UnsafeString((utils.RandStringBytesMaskImprSrcUnsafe(32)))
q.ClientSecret = utils.UnsafeString((utils.RandStringBytesMaskImprSrcUnsafe(128)))
Expand Down
5 changes: 3 additions & 2 deletions models/oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ func GetOAuthByClientID(db *gorm.DB, clientID string) (*APIOAuth, error) {

func CreateOAuth(db *gorm.DB, o *OAuth) (*OAuth, error) {
err := getDBSession(db).
Debug().
Create(&o).
Error
if err != nil {
Expand All @@ -129,11 +130,11 @@ func CreateOAuth(db *gorm.DB, o *OAuth) (*OAuth, error) {
return o, nil
}

func UpdateOAuth(db *gorm.DB, o *OAuth) error {
func UpdateOAuth(db *gorm.DB, o *OAuth, id string) error {
err := getDBSession(db).
Debug().
Model(OAuth{}).
Where("id", o.ID).
Where("id = ?", id).
Updates(o).
Error
if err != nil {
Expand Down

0 comments on commit e024042

Please sign in to comment.