mirror of
https://github.com/mudabbir-ahmad/peworkshop.git
synced 2026-10-07 19:50:20 +00:00
17 lines
463 B
JavaScript
17 lines
463 B
JavaScript
// app/api/user/route.js
|
|
import { getServerSession } from 'next-auth/next';
|
|
import { authOptions } from '../auth/[...nextauth]/route';
|
|
|
|
export async function GET() {
|
|
const session = await getServerSession(authOptions);
|
|
|
|
if (!session) {
|
|
return Response.json({ error: 'Unauthorized' }, { status: 401 });
|
|
}
|
|
|
|
return Response.json({
|
|
id: session.user.id,
|
|
username: session.user.username,
|
|
role: session.user.role
|
|
});
|
|
} |