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

profile custom claims not updated after registration #1150

Open
capi1O opened this issue Nov 25, 2021 · 0 comments
Open

profile custom claims not updated after registration #1150

capi1O opened this issue Nov 25, 2021 · 0 comments

Comments

@capi1O
Copy link

capi1O commented Nov 25, 2021

I am using RRF v3.11.0, to verify if a user is logged in I do the following:

import { isLoaded, isEmpty } from 'react-redux-firebase';
import { useSelector } from 'react-redux';

const { auth, profile } = useSelector((state) => state.firebase);
const loaded = isLoaded(auth) && isLoaded(profile);
const loggedIn = loaded && !isEmpty(auth) && (profile?.token?.claims?.role === USER_ROLE);

the role is set by a firestore function onUserCreate which is called as you would have guess at sign up.

The value of the custom claim role "read" by my useSelector is however not updated, it is still undefined no matter how long I wait, whereas it is correctly set on "server" (on firestore).

The app needs to be reloaded and then the role value is as expected. Here is my RRF config:

const reactReduxFirebaseConfig = {
	userProfile: 'users',
	useFirestoreForProfile: true,
	attachAuthIsReady: true,
	updateProfileOnLogin: true,
	enableClaims: true,
};

If you wonder why I check this role before to grant the user access to my app, well, I have my reasons.

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