import "server-only"; import type { User } from "@supabase/supabase-js"; import { admin, required } from "./supabase"; import { displayNameSchema } from "@/shared/account"; export async function accountProfile(account: User) { const name = displayNameSchema.safeParse(account.user_metadata?.display_name); required( await admin() .from("profiles") .upsert( { id: account.id, display_name: name.success ? name.data : "Explorer", }, { onConflict: "id", ignoreDuplicates: true }, ) .select("id"), ); return required( await admin() .from("profiles") .select( "id,username,display_name,avatar_path,role,name_glow,glow_color,bug_finder,custom_prefix,custom_prefix_icon,account_status,account_reason,account_changed_at", ) .eq("id", account.id) .single(), ); }