| 55 | }; |
| 56 | |
| 57 | const signInWithSso = async (providerId: string) => { |
| 58 | setBusy(true); |
| 59 | setError(null); |
| 60 | // Better Auth redirects the browser to the IdP; on callback it lands on |
| 61 | // `callbackURL`, so the deep-link target survives the round trip the same |
| 62 | // way it does for the email form's post-login navigation. |
| 63 | const result = await authClient.signIn.oauth2({ |
| 64 | providerId, |
| 65 | callbackURL: postLogin, |
| 66 | }); |
| 67 | if (result.error) { |
| 68 | setBusy(false); |
| 69 | setError(result.error.message ?? "Sign in failed"); |
| 70 | } |
| 71 | }; |
| 72 | |
| 73 | const redeem = (event: FormEvent) => { |
| 74 | event.preventDefault(); |