Login state upon page reload if authenticated
andreas-lundgren-qlucore opened this issue · comments
Checklist
- I have looked into the Readme (Login/Calling an API) and have not found a suitable solution or answer.
- I have searched the issues and have not found a suitable solution or answer.
- I have searched the Auth0 Community forums and have not found a suitable solution or answer.
- I agree to the terms within the Auth0 Code of Conduct.
Describe the problem you'd like to have solved
If I run the 01-LOGIN
application and login, then reload the page, the GUI is in a non logged-in state. Once pressing the "Log in" button (qsLoginBtn
), I am automatically logged in. I use the New Login Experience and Refresh Tokens as far as I can tell, have tried the suggestions in the FAQ.
I had a local "fix" for this since May 2023, using this sample application to quickly obtain my JWT in our test environment. But this "fix" stoped working this week, and I spent two days trying to figure out why. Still with no success.
I simply added an else statement calling the login()
function for this code block in the window.onload
hook:
if (isAuthenticated) {
console.log("> User is authenticated");
window.history.replaceState({}, document.title, window.location.pathname);
updateUI();
return;
}
// New:
else {
login();
}
Up until this week, this code has been working as I expected (if not actually authenticated, open login page, else login silently in the background). But no this change causes the page to go into a reload-loop, and I cannot figure out what changed. I have tried to lock down the SDK to an earlier version, to latest version, tested different browsers etc, all with the same result...
Describe the ideal solution
I think that doing a silent "login" if the user is indeed authenticated would be beneficial in many applications, and I suggest that this is added to the sample application
Alternatives and current workarounds
It would be very interesting to find out why my quick-fix, adding a login stopped working. I swear it worked a week ago! 🤯
Additional context
No response