diff --git a/src/pages/api/auth/confirm.ts b/src/pages/api/auth/confirm.ts
new file mode 100644
index 0000000..9e7fc1a
--- /dev/null
+++ b/src/pages/api/auth/confirm.ts
@@ -0,0 +1,20 @@
+import type { APIRoute } from "astro"
+import { supabase } from "@library/supabase"
+
+export const POST: APIRoute = async ({ request, redirect }) => {
+ const formData = await request.formData()
+ const EMAIL = formData.get("email")?.toString()
+ const OTP = formData.get("code")?.toString()
+
+ if (!OTP) {
+ return new Response("Code required", { status: 400 })
+ }
+
+ const { error } = await supabase.auth.verifyOtp({type: 'email', token: OTP, email: EMAIL})
+
+ if (error) {
+ return new Response(error.message, { status: 500 })
+ }
+
+ return redirect("/?=welcome")
+}
diff --git a/src/pages/api/auth/register.ts b/src/pages/api/auth/register.ts
index 42dfa6d..aae5360 100644
--- a/src/pages/api/auth/register.ts
+++ b/src/pages/api/auth/register.ts
@@ -15,6 +15,7 @@ export const POST: APIRoute = async ({ request, redirect }) => {
// https://supabase.com/docs/reference/javascript/auth-signup?example=sign-up-with-additional-user-metadata
const { error } = await supabase.auth.signUp({
options: {
+ emailRedirectTo: "http://localhost:4321/?=welcome",
data: {
full_name: name,
avatar_url: avatar_url,
@@ -32,5 +33,5 @@ export const POST: APIRoute = async ({ request, redirect }) => {
return new Response(error.message, { status: 500 })
}
- return redirect("/")
+ return redirect("/email-confirm")
}
diff --git a/src/pages/email-confirm.astro b/src/pages/email-confirm.astro
new file mode 100644
index 0000000..3d2f693
--- /dev/null
+++ b/src/pages/email-confirm.astro
@@ -0,0 +1,20 @@
+---
+import Base from "@layouts/Base.astro"
+---
+
+