| 1 | "use client"; |
| 2 | |
| 3 | import { useAuth } from "@better-auth-ui/react"; |
| 4 | import { useCallback } |
| 5 | import { |
| 6 | isTwoFactorRedirect, |
| 7 | storeTwoFactorMethods, |
| 8 | TWO_FACTOR_PLUGIN_ID, |
| 9 | } from "./two-factor-methods"; |
| 10 | |
| 11 | /** Resolve what happens after a sign-in request succeeds. */ |
| 12 | export function useSignInContinuation() |
| 13 | const { basePaths, |
| 14 | |
| 15 | const twoFactorPath = |
| 16 | (plugin) => |
| 17 | )?.viewPaths?.auth?. |
| 18 | |
| 19 | return useCallback( |
| 20 | (data: unknown |
| 21 | if (twoFactorPath && |
| 22 | storeTwoFactorMethods(data.twoFactorMethods |
| 23 | |
| 24 | navigate({ |
| 25 | to: `${basePaths. |
| 26 | }); |
| 27 | return; |
| 28 | } |
| 29 | |
| 30 | navigate({ to: |
| 31 | }, |
| 32 | [basePaths.auth, |
| 33 | ); |
| 34 | } |