import { createClient } from "@/utils/supabase/server"; import Link from "next/link"; import { cookies } from "next/headers"; import { redirect } from "next/navigation"; import { insertUserProfile } from "@/utils/supabase/supabaseutils"; export default async function AuthButton() { const cookieStore = cookies(); const supabase = createClient(cookieStore); const { data, data: { user }, } = await supabase.auth.getUser(); //profiles表 插入用户信息 await insertUserProfile(data, supabase); // console.log("1111 in AuthButton user:", user); const signOut = async () => { "use server"; const cookieStore = cookies(); const supabase = createClient(cookieStore); await supabase.auth.signOut(); return redirect("/login"); }; return user ? (
Hey, {user.email}! {/*
VIP
*/}
) : ( Login ); }