delete sessions when admin is deleted

This commit is contained in:
2023-08-28 16:41:41 +02:00
parent 0958ff21b6
commit 5a1fa2cc95
3 changed files with 54 additions and 16 deletions

View File

@@ -22,18 +22,22 @@ export const POST = (async ({ request, cookies }) => {
username == env.ADMIN_USER &&
password == env.ADMIN_PASSWORD
) {
cookies.set('session', addSession(new Permissions(Permissions.allPermissions())), {
path: `${publicEnv.PUBLIC_BASE_PATH}/admin`,
maxAge: 60 * 60 * 24 * 90,
httpOnly: true,
secure: true
});
cookies.set(
'session',
addSession({ id: -1, permissions: new Permissions(Permissions.allPermissions()) }),
{
path: `${publicEnv.PUBLIC_BASE_PATH}/admin`,
maxAge: 60 * 60 * 24 * 90,
httpOnly: true,
secure: true
}
);
return new Response();
}
const user = await Admin.findOne({ where: { username: username } });
if (user && user.validatePassword(password)) {
cookies.set('session', addSession(user.permissions), {
cookies.set('session', addSession(user), {
path: `${publicEnv.PUBLIC_BASE_PATH}/admin`,
maxAge: 60 * 60 * 24 * 90,
httpOnly: true,