-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
108ec7c
commit cfafafb
Showing
17 changed files
with
187 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,26 @@ | ||
import { NextRequest, NextResponse } from 'next/server'; | ||
import { adminAuth as auth } from '@/lib/firebaseAdmin'; | ||
import { NextRequest, NextResponse } from "next/server"; | ||
import { adminAuth as auth } from "@/lib/firebaseAdmin"; | ||
|
||
export async function POST(req: NextRequest) { | ||
const { idToken } = await req.json(); | ||
|
||
try { | ||
const expiresIn = 60 * 60 * 24 * 5 * 1000; // 5 days | ||
const sessionCookie = await auth.createSessionCookie(idToken, { expiresIn }); | ||
|
||
const response = NextResponse.json({ status: 'success' }); | ||
response.cookies.set('session', sessionCookie, { | ||
maxAge: expiresIn, | ||
httpOnly: true, | ||
secure: process.env.NODE_ENV === 'production', | ||
path: '/' | ||
const sessionCookie = await auth.createSessionCookie(idToken, { | ||
expiresIn, | ||
}); | ||
|
||
|
||
const response = NextResponse.json({ status: "success" }); | ||
response.cookies.set("session", sessionCookie, { | ||
maxAge: expiresIn, | ||
httpOnly: true, | ||
secure: process.env.NODE_ENV === "production", | ||
path: "/", | ||
}); | ||
|
||
return response; | ||
} catch (error) { | ||
console.error('Error creating session:', error); | ||
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); | ||
console.error("Error creating session:", error); | ||
return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import { NextRequest, NextResponse } from 'next/server'; | ||
import { adminAuth as auth } from '@/lib/firebaseAdmin'; | ||
import { NextRequest, NextResponse } from "next/server"; | ||
import { adminAuth as auth } from "@/lib/firebaseAdmin"; | ||
|
||
export async function GET(req: NextRequest) { | ||
const sessionCookie = req.cookies.get('session')?.value || ''; | ||
const sessionCookie = req.cookies.get("session")?.value || ""; | ||
|
||
try { | ||
const decodedClaims = await auth.verifySessionCookie(sessionCookie, true); | ||
return NextResponse.json({ authenticated: true, user: decodedClaims }); | ||
} catch (error) { | ||
return NextResponse.json({ authenticated: false }, { status: 401 }); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,7 +78,6 @@ | |
} | ||
} | ||
|
||
|
||
@keyframes fadeIn { | ||
from { | ||
opacity: 0; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.