Skip to content

profile custom claims not updated after registration #1150

Open
@capi1O

Description

@capi1O

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions