Skip to content

Commit

Permalink
MInor fix to await for clain before request it
Browse files Browse the repository at this point in the history
When requesting to add a claim for the first time, it's possible that it may not be ready yet. Waiting for it will prevent errors. Additionally, Firebase might return a cached `idToken`, which can be forced using `(true)` as a parameter.
  • Loading branch information
runtimecrasher committed Apr 14, 2024
1 parent 6b9a8d0 commit cd4bcae
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ export const AuthProvider = ({ children }) => {
setLoading(false)
setCurrentUser(user)
if (user) {
addUserClaim({email: user.email})
const token = await user.getIdToken();
await addUserClaim({email: user.email})
const token = await user.getIdToken(true);
setIdToken(token);
}
});
Expand Down

0 comments on commit cd4bcae

Please sign in to comment.