Email provider: refresh session object after user name updated #1620
-
Hi, I'm new to developing with React & Nextjs and this library has taken a lot of pain out of authentication. I set up the email provider and it works like a dream. The only issue i am facing is that the email provider leaves the field user.name = null. On the nav bar: if the session.user.name is null, I display the session.user.email. If it's not null, i display the session.user.name I created a user form to update the user name. The update to the database works fine. But the user name after the update doesn't appear on the nav bar, the email address remains. Unless i do a window refresh. What do i need to do to refresh the session object so that it correctly displays the session.user.name once it's been updated? Thanks in advance for you help! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
Hello, why don't you update the value with React after the form has been successfully submitted? |
Beta Was this translation helpful? Give feedback.
-
From the docs:
So calling Link to docs: https://next-auth.js.org/getting-started/client#options Objectively, this is well hidden and not straightforward in the documentation, but hopefully will work. If it does, we might want to open a "good first issue" asking someone to highlight this better in our docs. |
Beta Was this translation helpful? Give feedback.
-
@balazsorban44 Not being able to use getSession to trigger the session udpate is an existing issue #596. So, @StefanSelfTaught I ended up doing what you suggested, I used the workaround here: #371 (comment) Thanks guys for pointing me in the right direction! |
Beta Was this translation helpful? Give feedback.
Hello, why don't you update the value with React after the form has been successfully submitted?