Currently in the process of developing a website using NextJS 14 and Auth.js v5. The issue I'm facing pertains to the settings page post user login redirection. Depending on whether the user logs in using OAuth like Github or with Credentials, there should be varying degrees of settings that can be modified (such as enabling 2FA, etc.). However, at present, after logging in with credentials, the session does not update automatically and a site refresh is required to view the updated session data. This issue seems to be related to the useSession hook from auth.js, but resolving it has been challenging for me. As someone who is relatively new to NextJS and Auth.js, please pardon any imprecise language used. I welcome the opportunity to provide further clarification if needed. Provided below are images and code snippets. For the complete code, please refer to GitHub: https://github.com/EnXan/UTP. I have followed a tutorial where everything functions as expected: https://github.com/Hombre2014/nextjs-14-auth-v5-tutorial)
LoginPage https://i.sstatic.net/2cx7oXM6.png
Settings page after log in with credentials (no session available) https://i.sstatic.net/GPyzfPYQ.png
Settings page after reloading https://i.sstatic.net/7wBKiVeK.png
Settings page after log in with Github (no need to refresh page; everything works here) https://i.sstatic.net/JfNcsG42.png
settings (page.tsx)
Code Snippet Here
Root-Layout (layout.tsx)
Code Snippet Here
useCurrentUser-Hook
Code Snippet Here