Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login state upon page reload if authenticated #141

Open
4 tasks done
andreas-lundgren-qlucore opened this issue Jan 17, 2024 · 0 comments
Open
4 tasks done

Login state upon page reload if authenticated #141

andreas-lundgren-qlucore opened this issue Jan 17, 2024 · 0 comments

Comments

@andreas-lundgren-qlucore
Copy link

andreas-lundgren-qlucore commented Jan 17, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant