| Total Complexity | 2 |
| Complexity/F | 2 |
| Lines of Code | 27 |
| Function Count | 1 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import { |
||
| 2 | Controller, |
||
| 3 | InternalServerErrorException, |
||
| 4 | Post, |
||
| 5 | Req, |
||
| 6 | Res |
||
| 7 | } from '@nestjs/common'; |
||
| 8 | import { Request, Response } from 'express'; |
||
| 9 | import { WithName } from 'src/Infrastructure/Common/ExtendedRouting/WithName'; |
||
| 10 | |||
| 11 | @Controller('logout') |
||
| 12 | export class LogoutController { |
||
| 13 | @Post() |
||
| 14 | @WithName('logout') |
||
| 15 | public async post(@Req() req: Request, @Res() res: Response): Promise<void> { |
||
| 16 | const err = await new Promise(resolve => { |
||
| 17 | req.logout(err => resolve(err)); |
||
| 18 | }); |
||
| 19 | |||
| 20 | if (err) { |
||
| 21 | throw new InternalServerErrorException('Failed to log out'); |
||
| 22 | } |
||
| 23 | |||
| 24 | res.redirect(303, '/login'); |
||
| 25 | } |
||
| 26 | } |
||
| 27 |