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

refactor(core): allow passing optional check params to Authenticated … #6483

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

reedwane
Copy link

…component

PR Checklist

Please check if your PR fulfills the following requirements:

Bugs / Features

What is the current behavior?

The Authenticated component doesn't take extra params for the useIsAuthenticated hook to check the auth status

What is the new behavior?

The component now has params in the props which is then passed to the authenticated hook call, which already allows for params: any
fixes (#6309)

Notes for reviewers

@reedwane reedwane requested a review from a team as a code owner November 11, 2024 10:15
Copy link

changeset-bot bot commented Nov 11, 2024

🦋 Changeset detected

Latest commit: ecc5f6b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@refinedev/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member

@BatuhanW BatuhanW left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @reedwane thanks for the quick and neat PR! LGTM 👍🏼 We'll release it in December '24 release. ❤️

Comment on lines +623 to +628
check: async ({ params }) => {
// Simulate failed authentication based on params
return params?.allowAuth
? { authenticated: true }
: { authenticated: false, redirectTo: "/login" };
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optionally, this can be simplified. Passing a mockCheck here and assert that mockCheck is called with given mockParams. But this also works because you are checking if redirect is called, so it's a matter of taste.

@BatuhanW
Copy link
Member

Oh, a minor thing I forgot, we could also update Authenticated component documentation and mention that params can be passed to AuthProvider's check method.

@BatuhanW BatuhanW self-requested a review November 11, 2024 10:47
@reedwane
Copy link
Author

Oh. Okay @BatuhanW. sadly I have to run now...

I'm not sure why the linting is throwing an error... I installed the biome extension, but can't get it to format the file for some reason.... is this something someone else can easily help with?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants