[GH-ISSUE #772] OAuth Provider doesn't update user #8423

Closed
opened 2026-04-13 03:29:25 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @skip-pp on GitHub (Dec 5, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/772

Describe the bug

If I login using the genericOAuth plugin, custom attributes from the provider are not updated in the DB if a user exist.

I'm using keycloak, with groups attributes. Each group has the same attribute key, only the value differ.
If I'm in the group1 with an attribute like foo: bar, user is created in the DB with the value.
If I logout, switch to group2 with the same attribute key but with a different value foo: xyz, login again, the user in the DB is not updated

To Reproduce

Steps to reproduce the behavior:

With empty DB

  1. Login for the first time using genericOAuth plugin
  2. User is created with correct keycloak group attribute in DB : foo: bar
  3. Logout
  4. Change user group in keycloak (group attribute become : foo: xyz)
  5. Login
  6. DB user is not updated (attribute is still : foo: bar)

Output from mapProfileToUser :

{
  ...,
  foo: xyz
}

Output from session :

{
  session: {
    ...,
  },
  user: {
    ...,
    foo: bar,
  }
}
Originally created by @skip-pp on GitHub (Dec 5, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/772 **Describe the bug** If I login using the genericOAuth plugin, custom attributes from the provider are not updated in the DB if a user exist. I'm using keycloak, with groups attributes. Each group has the same attribute key, only the value differ.\ If I'm in the group1 with an attribute like **foo: bar**, user is created in the DB with the value.\ If I logout, switch to group2 with the same attribute key but with a different value **foo: xyz**, login again, the user in the DB is not updated **To Reproduce** Steps to reproduce the behavior: *With empty DB* 1. Login for the first time using genericOAuth plugin 2. User is created with correct keycloak group attribute in DB : **foo: bar** 3. Logout 4. Change user group in keycloak (group attribute become : **foo: xyz**) 5. Login 6. DB user is not updated (attribute is still : **foo: bar**) Output from mapProfileToUser : ```ts { ..., foo: xyz } ``` Output from session : ```ts { session: { ..., }, user: { ..., foo: bar, } } ```
GiteaMirror added the locked label 2026-04-13 03:29:25 -05:00
Author
Owner

@skip-pp commented on GitHub (Dec 18, 2024):

bug is still here. user is not updated on oauth login
better-auth: 1.0.22

<!-- gh-comment-id:2550948474 --> @skip-pp commented on GitHub (Dec 18, 2024): bug is still here. user is not updated on oauth login better-auth: 1.0.22
Author
Owner

@Bekacru commented on GitHub (Dec 18, 2024):

@skip-pp we've actually removed it altogether after reconsideration. Since user info is managed by the app after registration for example, if the user updates their name in your app, it shouldn't be overridden on the next re-login because they've also updated their with the provider.

<!-- gh-comment-id:2550966153 --> @Bekacru commented on GitHub (Dec 18, 2024): @skip-pp we've actually removed it altogether after reconsideration. Since user info is managed by the app after registration for example, if the user updates their name in your app, it shouldn't be overridden on the next re-login because they've also updated their with the provider.
Author
Owner

@cookli0721 commented on GitHub (Mar 24, 2025):

In a similar situation, my application is an internal company platform where user information depends on updates from a unified provider. Could you provide a configuration option to allow us to decide whether to update user information or not?

<!-- gh-comment-id:2747415832 --> @cookli0721 commented on GitHub (Mar 24, 2025): In a similar situation, my application is an internal company platform where user information depends on updates from a unified provider. Could you provide a configuration option to allow us to decide whether to update user information or not?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#8423