-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): Implement use reset password factor logic (#3750)
- Loading branch information
1 parent
1066eaa
commit aa0efec
Showing
3 changed files
with
31 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { useClerk } from '@clerk/clerk-react'; | ||
import type { ResetPasswordCodeFactor, SignInStrategy } from '@clerk/types'; | ||
|
||
const resetPasswordStrategies: SignInStrategy[] = ['reset_password_phone_code', 'reset_password_email_code']; | ||
export const isResetPasswordStrategy = (strategy: SignInStrategy | string | null | undefined) => | ||
!!strategy && resetPasswordStrategies.includes(strategy as SignInStrategy); | ||
|
||
export function useResetPasswordFactor() { | ||
const clerk = useClerk(); | ||
|
||
return clerk.client.signIn.supportedFirstFactors.find(({ strategy }) => isResetPasswordStrategy(strategy)) as | ||
| ResetPasswordCodeFactor | ||
| undefined; | ||
} |