Skip to content

Commit

Permalink
Add users table name explicitly to avoid naming conflict in query
Browse files Browse the repository at this point in the history
This fixes multiple times reference of same table in a query
which is not using aliases

Signed-off-by: Shiv Verma <[email protected]>
  • Loading branch information
pratap0007 committed Jan 11, 2024
1 parent 5fae163 commit a320f0d
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions api/pkg/auth/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (r *request) insertData(gitUser goth.User, code, provider string) error {
var acc model.Account
var user model.User

userQuery := r.db.Model(&model.User{}).
userQuery := r.db.Table("users").
Where("email = ?", gitUser.Email)

// Check if user exist
Expand Down Expand Up @@ -154,7 +154,6 @@ func (r *request) insertData(gitUser goth.User, code, provider string) error {
} else { // when the email of user already exists
// Update the users table with the auth code
if err := userQuery.Update("code", code).Error; err != nil {
r.log.Error(err)
return err
}

Expand Down

0 comments on commit a320f0d

Please sign in to comment.