fix(striker-ui-api): clear cookies on logout

main
Tsu-ba-me 2 years ago
parent f49ffd709f
commit 252c552771
  1. 12
      striker-ui-api/src/lib/request_handlers/auth/logout.ts

@ -1,17 +1,19 @@
import { RequestHandler } from 'express';
import { cname } from '../../cname';
import { stdout } from '../../shell';
export const logout: RequestHandler = (request, response) => {
request.session.destroy((error) => {
let scode = 204;
if (error) {
scode = 500;
stdout(`Failed to destroy session upon logout; CAUSE: ${error}`);
return response.status(500).send();
}
response.status(scode).send();
response.clearCookie(cname('user'));
response.clearCookie(cname('sid'));
return response.status(204).send();
});
};

Loading…
Cancel
Save