parent
f49ffd709f
commit
252c552771
1 changed files with 7 additions and 5 deletions
@ -1,17 +1,19 @@ |
|||||||
import { RequestHandler } from 'express'; |
import { RequestHandler } from 'express'; |
||||||
|
|
||||||
|
import { cname } from '../../cname'; |
||||||
import { stdout } from '../../shell'; |
import { stdout } from '../../shell'; |
||||||
|
|
||||||
export const logout: RequestHandler = (request, response) => { |
export const logout: RequestHandler = (request, response) => { |
||||||
request.session.destroy((error) => { |
request.session.destroy((error) => { |
||||||
let scode = 204; |
|
||||||
|
|
||||||
if (error) { |
if (error) { |
||||||
scode = 500; |
|
||||||
|
|
||||||
stdout(`Failed to destroy session upon logout; CAUSE: ${error}`); |
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…
Reference in new issue