Improve MineGeo exploration and mapping features
This commit is contained in:
@@ -2,6 +2,7 @@ import "server-only";
|
||||
import { createClient } from "@supabase/supabase-js";
|
||||
import { createServerClient } from "@supabase/ssr";
|
||||
import { cookies } from "next/headers";
|
||||
import { cache } from "react";
|
||||
import type { Database } from "@/shared/database";
|
||||
let singleton: ReturnType<typeof createClient<Database>> | undefined;
|
||||
export function admin() {
|
||||
@@ -36,13 +37,18 @@ export async function authClient() {
|
||||
},
|
||||
);
|
||||
}
|
||||
export async function user() {
|
||||
export const user = cache(async function user() {
|
||||
if (
|
||||
!process.env.NEXT_PUBLIC_SUPABASE_URL ||
|
||||
!process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY
|
||||
)
|
||||
return null;
|
||||
const client = await authClient();
|
||||
const {
|
||||
data: { user },
|
||||
} = await client.auth.getUser();
|
||||
return user;
|
||||
}
|
||||
});
|
||||
export function required<T>(result: {
|
||||
data: T;
|
||||
error: { message: string } | null;
|
||||
|
||||
Reference in New Issue
Block a user