Improve MineGeo exploration and mapping features
This commit is contained in:
27
lib/profile.ts
Normal file
27
lib/profile.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
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,display_name,role")
|
||||
.eq("id", account.id)
|
||||
.single(),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user