← back to Grant
app/api/auth/session/route.ts
26 lines
import { NextRequest, NextResponse } from 'next/server';
import { verifyAuthWithOrg, resolveSessionIdentity } from '@/lib/auth';
export async function GET(request: NextRequest) {
const session = verifyAuthWithOrg(request);
if (!session) {
return NextResponse.json({ authenticated: false }, { status: 401 });
}
// Resolve the users-table account (role/isAdmin) so the app-gate login
// is "recognized" as an admin-level identity the Live/Admin toggle keys off.
const identity = await resolveSessionIdentity(session);
return NextResponse.json({
authenticated: true,
user: identity.user,
role: identity.role,
isAdmin: identity.isAdmin,
canWrite: identity.canWrite,
canUseAI: identity.canUseAI,
email: identity.email,
displayName: identity.displayName,
});
}