Skip to content

Commit 2a9d63d

Browse files
committed
address PR review comments
1 parent 39b8604 commit 2a9d63d

2 files changed

Lines changed: 29 additions & 8 deletions

File tree

frontend/components/auth/LoginForm.tsx

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,34 @@ export function LoginForm({
8383
async function resendVerification() {
8484
if (!email) return;
8585

86-
await fetch("/api/auth/resend-verification", {
87-
method: "POST",
88-
headers: { "Content-Type": "application/json" },
89-
body: JSON.stringify({ email }),
90-
});
86+
try {
87+
const res = await fetch("/api/auth/resend-verification", {
88+
method: "POST",
89+
headers: { "Content-Type": "application/json" },
90+
body: JSON.stringify({ email }),
91+
});
9192

92-
setVerificationSent(true);
93-
setErrorCode(null);
94-
setErrorMessage(null);
93+
const data = await res.json().catch(() => null);
94+
95+
if (!res.ok) {
96+
setErrorCode(data?.code ?? "RESEND_FAILED");
97+
setErrorMessage(
98+
data?.error ??
99+
"Failed to resend verification email. Please try again."
100+
);
101+
return;
102+
}
103+
104+
setVerificationSent(true);
105+
setErrorCode(null);
106+
setErrorMessage(null);
107+
} catch (err) {
108+
console.error("Resend verification failed:", err);
109+
setErrorCode("NETWORK_ERROR");
110+
setErrorMessage(
111+
"Network error. Please check your connection and try again."
112+
);
113+
}
95114
}
96115

97116
return (

frontend/lib/auth/safe-redirect.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ export function getSafeRedirect(
33
): string {
44
if (!raw) return "";
55

6+
if (raw.includes("\\")) return "";
7+
68
if (!raw.startsWith("/")) return "";
79
if (raw.startsWith("//")) return "";
810
if (raw.includes("://")) return "";

0 commit comments

Comments
 (0)