add update session
This commit is contained in:
@@ -44,6 +44,26 @@ export async function createSession(token: string, email: string) {
|
||||
});
|
||||
}
|
||||
|
||||
export async function updateSession() {
|
||||
const session = (await cookies()).get('session')?.value
|
||||
const payload = await decrypt(session)
|
||||
|
||||
if (!session || !payload) {
|
||||
return null
|
||||
}
|
||||
|
||||
const expiresAt = new Date(Date.now() + 60 * 60 * 1000);
|
||||
|
||||
const cookieStore = await cookies()
|
||||
cookieStore.set('session', session, {
|
||||
httpOnly: true,
|
||||
secure: false,
|
||||
expires: expiresAt,
|
||||
sameSite: 'lax',
|
||||
path: '/',
|
||||
});
|
||||
}
|
||||
|
||||
export async function getSessionData(type: 'token' | 'email'): Promise<string | null> {
|
||||
const cookieStore = await cookies();
|
||||
const sessionCookie = cookieStore.get('session')?.value;
|
||||
|
||||
Reference in New Issue
Block a user