Skip to content

add useAutoSignin hook #1476

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

Merged
merged 7 commits into from
Mar 12, 2025
Merged

Conversation

aBytex
Copy link
Contributor

@aBytex aBytex commented Jan 25, 2025

Closes/fixes #1475

Checklist

  • [x ] This PR makes changes to the public API
  • [x ] I have included links for closing relevant issue numbers

@aBytex aBytex changed the title Feature/use auto signin hook feature/use auto signin hook Jan 25, 2025
@aBytex aBytex changed the title feature/use auto signin hook feature/useAutoSignin hook Jan 25, 2025
@pamapa
Copy link
Member

pamapa commented Mar 1, 2025

Thanks for providing this. Question why do you need signinSilent? signinRedirect and signinPopup are the natural choices. where signinSilent is used behind the scene to automatically update, which is already handled with useAuth...

@aBytex
Copy link
Contributor Author

aBytex commented Mar 8, 2025

Hello @pamapa ,

excuse me for the late answer - unfortanetly I was ill and thus not able to answer asap.

We mostly use signinRedirect and ocassionally signinPopup. So as you said, we too only need these.
I just added the signinSilent as option, because I was unsure if there are other cases I overlooked or you have special needs for. Thus I just tried to not limit it unknowingly.

Based on you comment I assume, it would be sufficient to pass either signinRedirect or signinPopup as options to the hook.

Update: I adjusted the pull request to only allow signinRedirect and signinPopup as options.

💡: Fix tsdoc based on api extractor warnings
@pamapa pamapa added this to the 3.3.0 milestone Mar 10, 2025
type UseAutoSignInReturn = {
isLoading: boolean;
isAuthenticated: boolean;
isError: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

Lets use the same name/type for error as already used in useAuth: error?: Error;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I changed it to return the error as in useAuth instead and thus adapted the type to Pick return types from the already defined AuthState interface.

Please check if you are happy with that🙂

@pamapa pamapa added the enhancement New feature or request label Mar 10, 2025
@pamapa pamapa changed the title feature/useAutoSignin hook add useAutoSignin hook Mar 10, 2025
@pamapa
Copy link
Member

pamapa commented Mar 10, 2025

looks good, there is one last small thing remaining (see above)

@pamapa pamapa merged commit d784f65 into authts:main Mar 12, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🎉: Hook to automatically sign in
2 participants