Replace entire repo content with code from /root/shahikitchen-google/
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { cookies } from 'next/headers';
|
||||
import {
|
||||
CUSTOMER_SESSION_COOKIE,
|
||||
getClearedCustomerSessionCookieOptions,
|
||||
} from '@/infrastructure/auth/customer-session';
|
||||
import {
|
||||
ADMIN_SESSION_COOKIE,
|
||||
getAdminSessionCookieOptions,
|
||||
} from '@/infrastructure/auth/admin-session';
|
||||
|
||||
export async function POST() {
|
||||
const cookieStore = await cookies();
|
||||
const clearedCustomer = getClearedCustomerSessionCookieOptions();
|
||||
const clearedAdmin = { ...getAdminSessionCookieOptions(), maxAge: 0, expires: new Date(0) };
|
||||
|
||||
cookieStore.set(CUSTOMER_SESSION_COOKIE, '', clearedCustomer);
|
||||
cookieStore.delete({ name: CUSTOMER_SESSION_COOKIE, path: '/' });
|
||||
|
||||
cookieStore.set(ADMIN_SESSION_COOKIE, '', clearedAdmin);
|
||||
cookieStore.delete({ name: ADMIN_SESSION_COOKIE, path: '/' });
|
||||
|
||||
const response = NextResponse.json({ ok: true });
|
||||
response.cookies.set(CUSTOMER_SESSION_COOKIE, '', clearedCustomer);
|
||||
response.cookies.set(ADMIN_SESSION_COOKIE, '', clearedAdmin);
|
||||
response.headers.set('Cache-Control', 'no-store');
|
||||
return response;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { isMenuManagerEmail } from '@/domain/auth/menu-managers';
|
||||
import { getCustomerSession } from '@/infrastructure/auth/customer-session';
|
||||
|
||||
export const dynamic = 'force-dynamic';
|
||||
|
||||
export async function GET() {
|
||||
const session = await getCustomerSession();
|
||||
const email = session?.email ?? null;
|
||||
return NextResponse.json({
|
||||
authenticated: Boolean(session),
|
||||
email,
|
||||
name: session?.name ?? null,
|
||||
isMenuManager: isMenuManagerEmail(email),
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user