Skip to content

fix(auth-info): autoInfo now updates when the authInfo is originally falsy#75

Merged
andrew-propelauth merged 2 commits intoPropelAuth:mainfrom
ealmeid:main
Mar 4, 2025
Merged

fix(auth-info): autoInfo now updates when the authInfo is originally falsy#75
andrew-propelauth merged 2 commits intoPropelAuth:mainfrom
ealmeid:main

Conversation

@ealmeid
Copy link
Copy Markdown
Contributor

@ealmeid ealmeid commented Mar 1, 2025

Description

In scenarios where the user starts off as logged out, and attempts to refresh the auth info manually, no changes to the store state will take place because _state.authInfo will already be null and will cause the check to fail.

This particular scenario occurs when leveraging the new ui based hooks. It goes as follows:

  1. User is not logged in
  2. User logs in successfully using the emailPasswordLogin call from useAuthFrontendApis.
  3. The refreshAuthInfo function from useAuthInfo is manually executed
  4. user & accessToken remain as null, even though the login flow has completed, and regardless if calls to the /refresh_token endpoint succeeed

Context: This happens because the flow that I'm currently trying to implement involves keeping the user on the root route before redirecting them to a new page, as there is some basic user-related information we'd like to show before redirecting.

I understand this check was originally put in place in this commit, but to compensate for it, optional chaining is put on both the _state & authInfo objects.

ealmeid added 2 commits March 1, 2025 00:00
…falsy

In scenarios where the user starts off as logged out, and attempts to refresh the auth info manually, no changes to the store state will take place because the  _state.authInfo will cause the check to fail
Copy link
Copy Markdown
Contributor

@andrew-propelauth andrew-propelauth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix, appreciate it!

@andrew-propelauth andrew-propelauth merged commit e577dfc into PropelAuth:main Mar 4, 2025
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

Successfully merging this pull request may close these issues.

2 participants