Skip to content

Commit

Permalink
Fix hooks usage within recommended replacement for claimCheck
Browse files Browse the repository at this point in the history
  • Loading branch information
ewanharris committed Feb 21, 2023
1 parent 29971e2 commit d1e297f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,14 @@ Our recommendation is to create another HOC that will perform the claim check an
```jsx
const withClaimCheck = (Component, myClaimCheckFunction, returnTo) => {
const { user } = useAuth0();
if (myClaimCheckFunction(user)) {
return <Component />
const WithClaimCheckComponent = () => {
const { user } = useAuth0();
if (myClaimCheckFunction(user)) {
return <Component />
}
Router.push(returnTo);
}
Router.push(returnTo);
return WithClaimCheckComponent;
}

const checkClaims = (claim?: User) => claim?.['https://my.app.io/jwt/claims']?.ROLE?.includes('ADMIN');
Expand Down

0 comments on commit d1e297f

Please sign in to comment.