feat: integrate NextAuth for authentication, refactor login and registration processes, and enhance middleware for session management
This commit is contained in:
17
src/lib/auth-utils.ts
Normal file
17
src/lib/auth-utils.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { auth } from "@/lib/auth";
|
||||
import type { UserData } from "@/lib/services/auth-server.service";
|
||||
|
||||
export async function getCurrentUser(): Promise<UserData | null> {
|
||||
const session = await auth();
|
||||
|
||||
if (!session?.user) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
id: session.user.id,
|
||||
email: session.user.email,
|
||||
roles: session.user.roles,
|
||||
authenticated: true,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user