feat: support guest session (#919)
This commit is contained in:
parent
24cb2ce19b
commit
9279135355
34 changed files with 741 additions and 288 deletions
21
app/(auth)/api/auth/guest/route.ts
Normal file
21
app/(auth)/api/auth/guest/route.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { signIn } from '@/app/(auth)/auth';
|
||||
import { isDevelopmentEnvironment } from '@/lib/constants';
|
||||
import { getToken } from 'next-auth/jwt';
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const redirectUrl = searchParams.get('redirectUrl') || '/';
|
||||
|
||||
const token = await getToken({
|
||||
req: request,
|
||||
secret: process.env.AUTH_SECRET,
|
||||
secureCookie: !isDevelopmentEnvironment,
|
||||
});
|
||||
|
||||
if (token) {
|
||||
return NextResponse.redirect(new URL('/', request.url));
|
||||
}
|
||||
|
||||
return signIn('guest', { redirect: true, redirectTo: redirectUrl });
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue