Skip to content

Commit

Permalink
refactor(api/guards): implements CanActivate
Browse files Browse the repository at this point in the history
  • Loading branch information
ZenSoftware committed May 4, 2022
1 parent a807f2d commit 020edea
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions apps/api/src/app/auth/guards/gql.guard.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ExecutionContext, Injectable } from '@nestjs/common';
import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common';
import { Reflector } from '@nestjs/core';
import { GqlExecutionContext } from '@nestjs/graphql';
import { AuthGuard } from '@nestjs/passport';
Expand All @@ -12,7 +12,7 @@ import { authLogic } from './auth-logic';
* Imitates RBAC rules for [ASP.NET Core](https://docs.microsoft.com/en-us/aspnet/core/security/authorization/roles?view=aspnetcore-6.0).
* **Super** users are granted unrestricted access.
*/
export class GqlGuard extends AuthGuard('jwt') {
export class GqlGuard extends AuthGuard('jwt') implements CanActivate {
constructor(private readonly reflector: Reflector) {
super();
}
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/app/auth/guards/http.guard.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ExecutionContext, Injectable } from '@nestjs/common';
import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common';
import { Reflector } from '@nestjs/core';
import { AuthGuard } from '@nestjs/passport';
import { Role } from '@prisma/client';
Expand All @@ -11,7 +11,7 @@ import { authLogic } from './auth-logic';
* Imitates RBAC rules for [ASP.NET Core](https://docs.microsoft.com/en-us/aspnet/core/security/authorization/roles?view=aspnetcore-6.0).
* **Super** users are granted unrestricted access.
*/
export class HttpGuard extends AuthGuard('jwt') {
export class HttpGuard extends AuthGuard('jwt') implements CanActivate {
constructor(private readonly reflector: Reflector) {
super();
}
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/app/auth/guards/reject-nested-create.guard.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ExecutionContext, HttpException, Injectable, Logger } from '@nestjs/common';
import { CanActivate, ExecutionContext, HttpException, Injectable, Logger } from '@nestjs/common';
import { GqlExecutionContext } from '@nestjs/graphql';

export function containsNestedCreate(args: any) {
Expand All @@ -21,7 +21,7 @@ export function containsNestedCreate(args: any) {
/**
* Rejects mutations with nested create argument
*/
export class RejectNestedCreateGuard {
export class RejectNestedCreateGuard implements CanActivate {
async canActivate(context: ExecutionContext) {
const ctx = GqlExecutionContext.create(context);

Expand Down

0 comments on commit 020edea

Please sign in to comment.