teableio/teable

View on GitHub
apps/nestjs-backend/src/features/auth/guard/social.guard.ts

Summary

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

@Injectable()
export class SocialGuard {
  async canActivate(context: ExecutionContext): Promise<boolean> {
    const req = context.switchToHttp().getRequest();
    const res = context.switchToHttp().getResponse();
    if (req?.query?.error === 'access_denied') {
      res.redirect('/auth/login');
      return false;
    }
    return true;
  }
}