From edb9939638d0ed1ea28b6909e5af49d71ff78e99 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Tue, 11 Nov 2025 22:23:54 +0000 Subject: [PATCH] Prettier format pending files --- api/user/link-dev-email.ts | 22 ++++++++++++---------- api/user/link-email.ts | 14 +++++++------- api/user/link-mrpiglr-accounts.ts | 16 ++++++++-------- api/user/resolve-linked-email.ts | 28 ++++++++++++++-------------- docs/EMAIL_LINKING_SYSTEM.md | 11 +++++++++++ 5 files changed, 52 insertions(+), 39 deletions(-) diff --git a/api/user/link-dev-email.ts b/api/user/link-dev-email.ts index 09f63581..6401f661 100644 --- a/api/user/link-dev-email.ts +++ b/api/user/link-dev-email.ts @@ -38,7 +38,7 @@ export default async (req: Request) => { if (mainError || !mainUser) { return new Response( JSON.stringify({ error: `User ${mainEmail} not found` }), - { status: 404, headers: { "Content-Type": "application/json" } } + { status: 404, headers: { "Content-Type": "application/json" } }, ); } @@ -57,17 +57,19 @@ export default async (req: Request) => { email: devEmail, user_id: mainUser.user_id, }), - { status: 200, headers: { "Content-Type": "application/json" } } + { status: 200, headers: { "Content-Type": "application/json" } }, ); } // Link .dev email to main user - const { error: linkError } = await supabase.from("user_email_links").insert({ - user_id: mainUser.user_id, - email: devEmail, - is_primary: false, - verified_at: new Date().toISOString(), - }); + const { error: linkError } = await supabase + .from("user_email_links") + .insert({ + user_id: mainUser.user_id, + email: devEmail, + is_primary: false, + verified_at: new Date().toISOString(), + }); if (linkError) { throw linkError; @@ -81,7 +83,7 @@ export default async (req: Request) => { mainEmail, userId: mainUser.user_id, }), - { status: 200, headers: { "Content-Type": "application/json" } } + { status: 200, headers: { "Content-Type": "application/json" } }, ); } catch (error: any) { console.error("[Link Dev Email Error]", error); @@ -90,7 +92,7 @@ export default async (req: Request) => { error: "Failed to link email", details: error.message, }), - { status: 500, headers: { "Content-Type": "application/json" } } + { status: 500, headers: { "Content-Type": "application/json" } }, ); } }; diff --git a/api/user/link-email.ts b/api/user/link-email.ts index c56a3cc8..966ef479 100644 --- a/api/user/link-email.ts +++ b/api/user/link-email.ts @@ -15,7 +15,7 @@ export default async (req: Request) => { if (!primaryEmail || !linkedEmail) { return new Response( JSON.stringify({ error: "Missing primaryEmail or linkedEmail" }), - { status: 400, headers: { "Content-Type": "application/json" } } + { status: 400, headers: { "Content-Type": "application/json" } }, ); } @@ -32,7 +32,7 @@ export default async (req: Request) => { error: "Primary email not found", details: primaryError?.message, }), - { status: 404, headers: { "Content-Type": "application/json" } } + { status: 404, headers: { "Content-Type": "application/json" } }, ); } @@ -49,7 +49,7 @@ export default async (req: Request) => { error: "Linked email not found", details: linkedError?.message, }), - { status: 404, headers: { "Content-Type": "application/json" } } + { status: 404, headers: { "Content-Type": "application/json" } }, ); } @@ -138,7 +138,7 @@ export default async (req: Request) => { // Insert or update primary email const primaryEmailExists = existingLinks?.some( - (l) => l.email === primaryEmail + (l) => l.email === primaryEmail, ); if (!primaryEmailExists) { await supabase.from("user_email_links").insert({ @@ -151,7 +151,7 @@ export default async (req: Request) => { // Insert or update linked email const linkedEmailExists = existingLinks?.some( - (l) => l.email === linkedEmail + (l) => l.email === linkedEmail, ); if (!linkedEmailExists) { await supabase.from("user_email_links").insert({ @@ -193,7 +193,7 @@ export default async (req: Request) => { { status: 200, headers: { "Content-Type": "application/json" }, - } + }, ); } catch (error: any) { console.error("[Email Linking Error]", error); @@ -205,7 +205,7 @@ export default async (req: Request) => { { status: 500, headers: { "Content-Type": "application/json" }, - } + }, ); } }; diff --git a/api/user/link-mrpiglr-accounts.ts b/api/user/link-mrpiglr-accounts.ts index 069e1a64..652c6f49 100644 --- a/api/user/link-mrpiglr-accounts.ts +++ b/api/user/link-mrpiglr-accounts.ts @@ -47,7 +47,7 @@ export default async (req: Request) => { email: primaryEmail, details: primaryError?.message, }), - { status: 404, headers: { "Content-Type": "application/json" } } + { status: 404, headers: { "Content-Type": "application/json" } }, ); } @@ -65,7 +65,7 @@ export default async (req: Request) => { email: linkedEmail, details: linkedError?.message, }), - { status: 404, headers: { "Content-Type": "application/json" } } + { status: 404, headers: { "Content-Type": "application/json" } }, ); } @@ -119,7 +119,7 @@ export default async (req: Request) => { if (discordLinks && discordLinks.length > 0) { console.log( - `[Email Linking] Found ${discordLinks.length} discord links, transferring...` + `[Email Linking] Found ${discordLinks.length} discord links, transferring...`, ); for (const link of discordLinks) { const { data: existing } = await supabase @@ -145,7 +145,7 @@ export default async (req: Request) => { if (web3Links && web3Links.length > 0) { console.log( - `[Email Linking] Found ${web3Links.length} web3 wallets, transferring...` + `[Email Linking] Found ${web3Links.length} web3 wallets, transferring...`, ); for (const wallet of web3Links) { const { data: existing } = await supabase @@ -172,7 +172,7 @@ export default async (req: Request) => { // Insert primary email const primaryEmailExists = existingLinks?.some( - (l) => l.email === primaryEmail + (l) => l.email === primaryEmail, ); if (!primaryEmailExists) { await supabase.from("user_email_links").insert({ @@ -185,7 +185,7 @@ export default async (req: Request) => { // Insert linked email const linkedEmailExists = existingLinks?.some( - (l) => l.email === linkedEmail + (l) => l.email === linkedEmail, ); if (!linkedEmailExists) { await supabase.from("user_email_links").insert({ @@ -230,7 +230,7 @@ export default async (req: Request) => { { status: 200, headers: { "Content-Type": "application/json" }, - } + }, ); } catch (error: any) { console.error("[Email Linking Error]", error); @@ -242,7 +242,7 @@ export default async (req: Request) => { { status: 500, headers: { "Content-Type": "application/json" }, - } + }, ); } }; diff --git a/api/user/resolve-linked-email.ts b/api/user/resolve-linked-email.ts index ed322d41..c7ea8667 100644 --- a/api/user/resolve-linked-email.ts +++ b/api/user/resolve-linked-email.ts @@ -12,10 +12,10 @@ export default async (req: Request) => { const { email } = await req.json(); if (!email) { - return new Response( - JSON.stringify({ error: "Email is required" }), - { status: 400, headers: { "Content-Type": "application/json" } } - ); + return new Response(JSON.stringify({ error: "Email is required" }), { + status: 400, + headers: { "Content-Type": "application/json" }, + }); } const supabase = getAdminClient(); @@ -34,10 +34,10 @@ export default async (req: Request) => { if (!emailLink) { // Email is not linked, return the email as-is - return new Response( - JSON.stringify({ primaryEmail: email }), - { status: 200, headers: { "Content-Type": "application/json" } } - ); + return new Response(JSON.stringify({ primaryEmail: email }), { + status: 200, + headers: { "Content-Type": "application/json" }, + }); } // Get the primary email for this user @@ -50,10 +50,10 @@ export default async (req: Request) => { if (profileError) { console.error("Profile lookup error:", profileError); // If we can't find the profile, return original email - return new Response( - JSON.stringify({ primaryEmail: email }), - { status: 200, headers: { "Content-Type": "application/json" } } - ); + return new Response(JSON.stringify({ primaryEmail: email }), { + status: 200, + headers: { "Content-Type": "application/json" }, + }); } return new Response( @@ -62,7 +62,7 @@ export default async (req: Request) => { linkedFrom: email, userId: emailLink.user_id, }), - { status: 200, headers: { "Content-Type": "application/json" } } + { status: 200, headers: { "Content-Type": "application/json" } }, ); } catch (error: any) { console.error("[Resolve Linked Email Error]", error); @@ -74,7 +74,7 @@ export default async (req: Request) => { { status: 500, headers: { "Content-Type": "application/json" }, - } + }, ); } }; diff --git a/docs/EMAIL_LINKING_SYSTEM.md b/docs/EMAIL_LINKING_SYSTEM.md index b3da4d3f..f7130f70 100644 --- a/docs/EMAIL_LINKING_SYSTEM.md +++ b/docs/EMAIL_LINKING_SYSTEM.md @@ -9,6 +9,7 @@ The email linking system allows users to authenticate with multiple email addres ### Database Tables #### `user_email_links` + Links multiple email addresses to a single user account. ```sql @@ -23,6 +24,7 @@ Links multiple email addresses to a single user account. ``` #### `user_profiles` (additions) + ```sql - primary_email: TEXT (the primary email for the account) - is_dev_account: BOOLEAN (marks if this is a developer account) @@ -72,6 +74,7 @@ UI shows: "Also logged in as mrpiglr@gmail.com" Resolve a linked email to its primary email address. **Request:** + ```json { "email": "mrpiglr@gmail.com" @@ -79,6 +82,7 @@ Resolve a linked email to its primary email address. ``` **Response (linked email):** + ```json { "primaryEmail": "mrpiglr@aethex.dev", @@ -88,6 +92,7 @@ Resolve a linked email to its primary email address. ``` **Response (non-linked email):** + ```json { "primaryEmail": "some@email.com" @@ -99,6 +104,7 @@ Resolve a linked email to its primary email address. Link two existing user accounts by merging one into the other. **Request:** + ```json { "primaryEmail": "mrpiglr@aethex.dev", @@ -107,6 +113,7 @@ Link two existing user accounts by merging one into the other. ``` **Response:** + ```json { "success": true, @@ -121,6 +128,7 @@ Link two existing user accounts by merging one into the other. Special endpoint to link the mrpiglr accounts. **Request:** + ```bash curl -X POST https://aethex.dev/api/user/link-mrpiglr-accounts \ -H "Authorization: Bearer mrpiglr-admin-token" \ @@ -128,6 +136,7 @@ curl -X POST https://aethex.dev/api/user/link-mrpiglr-accounts \ ``` **Response:** + ```json { "success": true, @@ -168,6 +177,7 @@ When two accounts are merged: ### For Developers (Dev Accounts) Developer accounts with `@aethex.dev` email: + - `is_dev_account = true` - `primary_email = "@aethex.dev email"` - Public profile shows work email @@ -209,6 +219,7 @@ curl -X POST https://aethex.dev/api/user/resolve-linked-email \ Applied via: `code/supabase/migrations/20250206_add_email_linking.sql` Includes: + - `user_email_links` table with RLS policies - `get_primary_user_by_email()` function - Columns on `user_profiles` for dev accounts and primary email