| 70 | @UseGuards(NotAuthRequiredCookieGuard) |
| 71 | @Post('logout') |
| 72 | async logout(@Req() req: Request, @Res() res: Response, @Session() session: Record<string, any>) { |
| 73 | if (req.user) { |
| 74 | const user = req.user as User |
| 75 | const nonce = (req as any).nonce as string |
| 76 | if (user && nonce && user.nonces.includes(nonce)) { |
| 77 | user.nonces = user.nonces.filter((un) => un !== nonce) |
| 78 | await this.userService.updateById(user._id, { nonces: user.nonces }) |
| 79 | } |
| 80 | } |
| 81 | try { |
| 82 | session.destroy(() => {}) |
| 83 | } catch {} |
| 84 | res.clearCookie('cj-token', { path: '/', domain: '.chainjet.io' }) |
| 85 | res.send({ success: true }) |
| 86 | return { ok: true } |
| 87 | } |
| 88 | |
| 89 | @Post('delete-cookie') |
| 90 | async deleteCookie(@Res() res: Response) { |