Testing new supabase structure
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
"use server";
|
||||
|
||||
import createClient from "@/lib/supa";
|
||||
|
||||
export async function getProfileById(id: string) {
|
||||
const supabase = await createClient();
|
||||
|
||||
const { error, data } = await supabase
|
||||
.from("profiles")
|
||||
.select("id, username, display_name, avatar_url, node_address")
|
||||
.eq("id", id)
|
||||
.maybeSingle();
|
||||
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
"use server";
|
||||
|
||||
import createClient from "@/lib/supa";
|
||||
|
||||
export default async function getSession() {
|
||||
const supabase = await createClient();
|
||||
const { error, data } = await supabase.auth.getSession();
|
||||
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return data.session?.user.id;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
"use server";
|
||||
|
||||
import createClient from "@/lib/supa";
|
||||
|
||||
export default async function loginServer(email: string, password: string) {
|
||||
const supabase = await createClient();
|
||||
|
||||
const { data, error } = await supabase.auth.signInWithPassword({
|
||||
email,
|
||||
password,
|
||||
});
|
||||
|
||||
if (error) {
|
||||
throw new Error(error.message);
|
||||
}
|
||||
|
||||
return data.user;
|
||||
}
|
||||
Reference in New Issue
Block a user