-
Notifications
You must be signed in to change notification settings - Fork 1.5k
updateName doesn't update the name in account page #311
Comments
Same issue, seems to be a problem with the handleRequest function in auth-helpers |
It looks like @thorwebdev rolled back some updates to the database schema where I added stronger RLS and cascaded changes from the The deleted migration file is here: As an alternative to cascading the changes, it's also possible to manually set up a trigger with the following SQL code:
|
Thank you for reaching out with both the commit and the alternative solution @chriscarrollsmith |
You mean the auth.users table is reverting to the original name, because it's getting the name from the third-party OAuth provider? No, that's not desired behavior. Maybe your approach is the right one, though. |
when i change it with
it edits the user_metadata correctly
but when i sign out and in with the provider again
from what i understand looking at what's happening when loging in with the provider is that the display name (full_name) gets overwritten on the action of signing in so i shouldn't try to change this value but the value in custom public users table to have the value up to date that doesn't get overwritten. |
Yes, I see. I think you're right, then. We should be updating the public users table, not the auth table. And we shouldn't be cascading name changes from auth to public. |
@chriscarrollsmith sorry, the main issue with that was that you're allowing users access to modify admin tables like |
Thanks for opening a PR @chriscarrollsmith. @thorwebdev Do you mean the PR @chriscarrollsmith just opened is not correct or the one you modified in the past (linked at the top by @chriscarrollsmith )? How about something like this?
|
Thanks, @thorwebdev! Yes, once I looked more closely at this, I understood why you rolled it back. I don't think your scenario would work, because there's no way for users to alter their ID in the auth.users table, but they could abuse it in other ways, like by altering their own subscription. Not sure what I was thinking, lol. I will update my latest PR to fix the broken types. |
He's talking about the past PR. The new PR I just opened should be okay. |
Alright! Thank you a lot @chriscarrollsmith ! Can I close this issue or the PR needs to be accepted first? |
This issue will be automatically closed once the PR is accepted. |
@szymonhernik's code above does work to update the public users table, but it bugs me that the user's name in auth metadata starts diverging from the one in the public/users table. I like @chriscarrollsmith's idea of using a trigger to keep these synchronized, but I'm wondering why even bother replicating the information across to the public users table at all? Why not just delete that row from the public table, and in account/page.tsx, swap in |
@k-thornton as in the previous comments, if you change it in the Auth table the name will be overwritten with the next sign in. |
issue perfectly fixed, after running the above SQL code in supabase "SQL Editor" |
this worked best for me too, keeps public.users and auth.users in sync |
simply, the updateName does update the full name in auth users but it's not reflected on the frontend as the value in display name is being taken from the users table. if you click on update name it says it's updated but on refresh it goes back to the first value.
in case i should provide more info let me know, thank you
The text was updated successfully, but these errors were encountered: