You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

25 lines
748 B

import {
type ExecutionContext,
Injectable,
type CanActivate
} from '@nestjs/common'
import { AuthGuard } from '@nestjs/passport'
import { type Request } from 'express'
@Injectable()
export class FtOauthGuard extends AuthGuard('42') {
async canActivate (context: ExecutionContext): Promise<boolean> {
const activate: boolean = (await super.canActivate(context)) as boolean
const request: Request = context.switchToHttp().getRequest()
await super.logIn(request)
return activate
}
}
@Injectable()
export class AuthenticatedGuard implements CanActivate {
async canActivate (context: ExecutionContext): Promise<boolean> {
const req: Request = context.switchToHttp().getRequest()
return req.isAuthenticated()
}
}