Skip to content

Commit 19df4cb

Browse files
committed
email verification api
1 parent b065771 commit 19df4cb

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

  • apps/codebility/app/api/email-verification
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { createClientServerComponent } from "@/utils/supabase/server";
2+
3+
export async function POST(request: Request) {
4+
5+
try {
6+
const formData = await request.formData()
7+
const email = formData.get('email')
8+
const stringEmail = email?.toString().trim().toLowerCase();
9+
10+
const supabase = await createClientServerComponent();
11+
12+
if (!stringEmail) {
13+
return Response.json({ message: "Email is required" }, { status: 400 });
14+
}
15+
16+
const { error, data } = await supabase.auth.resend({
17+
type: 'signup',
18+
email: stringEmail,
19+
});
20+
21+
if (error) {
22+
console.error("Error resending verification email:", error);
23+
return Response.json({ message: error.message }, { status: 400 });
24+
}
25+
26+
return Response.json({ email: stringEmail, data: data }, { status: 200 });
27+
} catch (error) {
28+
console.error("Error in email verification:", error);
29+
return Response.json({ message: "Internal Server Error" }, { status: 500 });
30+
}
31+
32+
}

0 commit comments

Comments
 (0)