-
Notifications
You must be signed in to change notification settings - Fork 209
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
Initialized flag on useAuth0 hook #561
Conversation
@cranberyxl I guess this can be achieved by checking both |
There is the time before the first request has completed, where there is no user and no error, while the first calls are being made to credentials manager, etc. This is indistinguishable from there is no user and no error and we've checked credentials manager. |
This is something I've been wanting as well. It would help cleanup some of the current authentication logic in my components |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @cranberyxl, this would be a great addition indeed. Can you use our auth0-react as inspiration and make the following changes?
- Rename the state to
isLoading
- Set it to
false
when the user is loaded from Credentials Manager or Login - Set it to
false
when there is an error - Set it to
true
when the Login is started again.
Anyone with any workarounds at the moment? |
Hi everyone, thanks a lot for the contribution. We have made a few more refactors and improvements to this PR. Please feel free to let us know your feedback on this. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
Looks great. It would be great to see a similar PR to https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-native-auth0 to keep the two in sync |
@cjpete Great catch. Any possibility you can help us with it? |
@poovamraj I think |
@cranberyxl It was decided to go with |
Changes
Add
isInitializing
flag touseAuth0
. This is true until we know that a user is either logged in or logged out. This allows us to prevent showing the logged in or logged out state of an app incorrectly while theuser
is returned from theCredentialsManager
.Testing
Checklist