Skip to content

Commit 7b9bfa8

Browse files
author
Boopathi
committed
fix: improve error handling for invalid or expired verification links and guide user to next steps
1 parent a717694 commit 7b9bfa8

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/app/auth/action/page.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ const ActionHandlerContent: React.FC = () => {
120120
});
121121

122122
React.useEffect(() => {
123-
const modeParam = searchParams.get('mode') as Action;
123+
const modeParam = searchParams.getAll('mode')[0] as Action; // Always get the first mode param
124124
const codeParam = searchParams.get('oobCode');
125125

126126
setMode(modeParam);
@@ -129,7 +129,7 @@ const ActionHandlerContent: React.FC = () => {
129129
if (!auth || !modeParam || !codeParam) {
130130
if(!auth) setLoading(false);
131131
if (!modeParam || !codeParam) {
132-
setError("Invalid action link. Please try again.");
132+
setError("This link is invalid, expired, or has already been used. Please log in or request a new verification email.");
133133
setLoading(false);
134134
}
135135
return;
@@ -200,7 +200,11 @@ const ActionHandlerContent: React.FC = () => {
200200
<XCircle className="h-12 w-12 text-destructive mx-auto mb-4" />
201201
<h2 className="text-2xl font-bold mb-2">Action Failed</h2>
202202
<p className="text-muted-foreground mb-6">{error}</p>
203-
<Button onClick={() => router.push('/')}>Go to Homepage</Button>
203+
<div className="flex flex-col gap-2 items-center">
204+
<Button onClick={() => router.push('/')} variant="secondary">Go to Homepage</Button>
205+
<Button onClick={() => router.push('/?action=login')} variant="default">Go to Login</Button>
206+
<Button onClick={() => setShowResendForm(true)} variant="outline">Resend Verification Email</Button>
207+
</div>
204208
</div>
205209
);
206210
}

0 commit comments

Comments
 (0)