Files
portabase/src/auth/current-user.ts
T

20 lines
417 B
TypeScript
Raw Normal View History

2024-11-03 21:12:40 +01:00
import {baseAuth} from "@/auth/auth";
import {User} from "@prisma/client";
export const currentUser = async () => {
const session = await baseAuth();
if (!session?.user) {
return null;
}
return session.user as User;
}
2024-11-29 19:25:44 +01:00
2024-11-03 21:12:40 +01:00
export const requiredCurrentUser = async () => {
const user = await currentUser();
if (!user) {
throw new Error("User not found");
}
return user;
}