teableio/teable

View on GitHub
apps/nestjs-backend/src/features/oauth/guard/oauth2-client.guard.ts

Summary

Maintainability
A
0 mins
Test Coverage
import type { ExecutionContext } from '@nestjs/common';
import { Injectable } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';

@Injectable()
export class OAuthClientGuard extends AuthGuard('oauth2-client-password') {
  async canActivate(context: ExecutionContext): Promise<boolean> {
    const result = (await super.canActivate(context)) as boolean;
    await super.logIn(context.switchToHttp().getRequest());
    return result;
  }
}