mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix(api): clear cookies on account/delete (#55260)
This commit is contained in:
committed by
GitHub
parent
7fdd9d0380
commit
dda9c929b0
@@ -362,6 +362,20 @@ describe('userRoutes', () => {
|
||||
expect(userTokens).toHaveLength(1);
|
||||
expect(userTokens[0]?.userId).toBe(otherUserId);
|
||||
});
|
||||
|
||||
test("POST deletes all the user's cookies", async () => {
|
||||
const res = await superPost('/account/delete');
|
||||
|
||||
const setCookie = res.headers['set-cookie'];
|
||||
expect(setCookie).toEqual(
|
||||
expect.arrayContaining([
|
||||
'jwt_access_token=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT',
|
||||
'_csrf=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT',
|
||||
'csrf_token=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT'
|
||||
])
|
||||
);
|
||||
expect(setCookie).toHaveLength(3);
|
||||
});
|
||||
});
|
||||
|
||||
describe('/account/reset-progress', () => {
|
||||
|
||||
@@ -119,7 +119,9 @@ export const userRoutes: FastifyPluginCallbackTypebox = (
|
||||
await fastify.prisma.user.delete({
|
||||
where: { id: req.user!.id }
|
||||
});
|
||||
void reply.clearCookie('sessionId');
|
||||
void reply.clearCookie('jwt_access_token');
|
||||
void reply.clearCookie('_csrf');
|
||||
void reply.clearCookie('csrf_token');
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user