mirror of
https://github.com/spchcap/speech.capital.git
synced 2026-01-14 08:38:42 +00:00
Feat: Clear auth cookies on logout
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
export async function onRequest({ request, env }) {
|
export async function onRequest() {
|
||||||
const sid = (request.headers.get('Cookie')||'').match(/session_id=([^;]+)/)?.[1];
|
const opts = `Domain=.speech.capital; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT`;
|
||||||
if (sid) await env.D1_SPCHCAP.prepare('DELETE FROM sessions WHERE id = ?').bind(sid).run();
|
const headers = new Headers();
|
||||||
|
headers.append('Set-Cookie', `auth_user=; ${opts}`);
|
||||||
const cookie = `session_id=; Domain=.speech.capital; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT`;
|
headers.append('Set-Cookie', `auth_hash=; ${opts}`);
|
||||||
return new Response(null, { status: 302, headers: { 'Set-Cookie': cookie, 'Location': '/' } });
|
headers.append('Location', '/');
|
||||||
|
return new Response(null, { status: 302, headers });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user