| Total Complexity | 1 |
| Complexity/F | 1 |
| Lines of Code | 19 |
| Function Count | 1 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import { ExecutionContext, Injectable } from '@nestjs/common'; |
||
| 2 | import { AuthGuard } from '@nestjs/passport'; |
||
| 3 | import { Request } from 'express'; |
||
| 4 | |||
| 5 | @Injectable() |
||
| 6 | export class LocalAuthGuard extends AuthGuard('local') { |
||
| 7 | constructor() { |
||
| 8 | super(); |
||
| 9 | } |
||
| 10 | |||
| 11 | async canActivate(context: ExecutionContext): Promise<boolean> { |
||
| 12 | // Perform log in using LocalStrategy |
||
| 13 | await super.canActivate(context); |
||
| 14 | const request = context.switchToHttp().getRequest() as Request; |
||
| 15 | await super.logIn(request); |
||
| 16 | return true; |
||
| 17 | } |
||
| 18 | } |
||
| 19 |