reactfire icon indicating copy to clipboard operation
reactfire copied to clipboard

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

Open jackcohen5 opened this issue 4 years ago • 2 comments

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.

jackcohen5 avatar Dec 23 '21 23:12 jackcohen5

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

tsdexter avatar May 01 '22 20:05 tsdexter

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! 🙇🏻‍♂️

capybarahero avatar Aug 11 '23 17:08 capybarahero