FirebaseExtended / reactfire

Hooks, Context Providers, and Components that make it easy to interact with Firebase.
https://firebaseopensource.com/projects/firebaseextended/reactfire/
MIT License
3.52k stars 401 forks source link

`validateCustomClaims` is not re-run when the user claims changes #493

Open jackcohen5 opened 2 years ago

jackcohen5 commented 2 years ago

Version info

React: 17.0.2

Firebase: 9.6.1

ReactFire: 4.2.1

Other (e.g. Node, browser, operating system) (if applicable):

Test case

const ExamleComponent = () => {
    const { data: { hasRequiredClaims } = {} } =  useSigninCheck({
        validateCustomClaims: (claims) => {
            return {
                hasRequiredClaims: claims.role === 'admin'
            }
        }
    })

    return <div>{hasRequiredClaims}</div>
}

Steps to reproduce

Add the above call to a React component and login a user with custom claims that match the condition. Trigger a re-render on the above component.

Expected behavior

Value of hasRequiredClaims changes after user is logged in to accurately reflect condition.

Actual behavior

Value of hasRequiredClaims does not change even after the component is re-rendered.

tsdexter commented 2 years ago

I think this may be related to a bug I just filed where validateCustomClaims is only called once in the component tree and subsequent calls return the same result https://github.com/FirebaseExtended/reactfire/issues/514

capybarahero commented 1 year ago

Hi @jhuleatt, Sorry for tagging you directly - I saw you assigned this task to yourself a few months ago.

Would you have any updates on this issue? Thanks a lot! 🙇🏻‍♂️