fix: auth

This commit is contained in:
David Nguyen
2025-02-09 00:46:25 +11:00
parent f5bfec1990
commit e128e9369e
13 changed files with 188 additions and 142 deletions

View File

@ -1,11 +1,10 @@
import { Hono } from 'hono';
import { deleteCookie, getSignedCookie } from 'hono/cookie';
import { invalidateSession, validateSessionToken } from '../lib/session/session';
import { deleteSessionCookie, getSessionCookie } from '../lib/session/session-cookies';
export const signOutRoute = new Hono().post('/signout', async (c) => {
// todo: secret
const sessionId = await getSignedCookie(c, 'secret', 'sessionId');
const sessionId = await getSessionCookie(c);
if (!sessionId) {
return new Response('No session found', { status: 401 });
@ -19,11 +18,7 @@ export const signOutRoute = new Hono().post('/signout', async (c) => {
await invalidateSession(session.id);
deleteCookie(c, 'sessionId', {
path: '/',
secure: true,
domain: 'example.com',
});
deleteSessionCookie(c);
return c.status(200);
});