feat(auth): add invite token handling to OTP sign-in and update metho… (#280)

* feat(auth): add invite token handling to OTP sign-in and update method descriptions
This commit is contained in:
Giancarlo Buomprisco
2025-06-14 14:31:30 +07:00
committed by GitHub
parent f95da27b8f
commit 1143a01727
6 changed files with 43 additions and 20 deletions

View File

@@ -4,6 +4,7 @@ import { useMemo } from 'react';
import dynamic from 'next/dynamic';
import Link from 'next/link';
import { useSearchParams } from 'next/navigation';
import { UserCheck } from 'lucide-react';
@@ -33,6 +34,14 @@ export function ExistingAccountHintImpl({
const { hasLastMethod, methodType, providerName, isOAuth } =
useLastAuthMethod();
const params = useSearchParams();
const isInvite = params.get('invite_token');
if (isInvite) {
signInPath = signInPath + '?invite_token=' + isInvite;
}
// Get the appropriate method description for the hint
// This must be called before any conditional returns to follow Rules of Hooks
const methodDescription = useMemo(() => {
@@ -42,13 +51,13 @@ export function ExistingAccountHintImpl({
switch (methodType) {
case 'password':
return 'email and password';
return 'auth:methodPassword';
case 'otp':
return 'email verification';
return 'auth:methodOtp';
case 'magic_link':
return 'email link';
return 'auth:methodMagicLink';
default:
return 'another method';
return 'auth:methodDefault';
}
}, [methodType, isOAuth, providerName]);