Skip to content

Commit

Permalink
fix: same but actually helpful?
Browse files Browse the repository at this point in the history
  • Loading branch information
Gobot1234 committed Apr 23, 2024
1 parent 9ad9ed5 commit 7646b1e
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { auth } from "@dbschema/interfaces";
import { CanActivate, ExecutionContext, Injectable } from "@nestjs/common";
import { CanActivate, ExecutionContext, HttpException, Injectable, InternalServerErrorException } from "@nestjs/common";
import { Reflector } from "@nestjs/core";
import type { Request } from "express";
import { ACTIONS_KEY, SUBJECT_KEY } from "../decorators/check-abilities-decorator";
Expand All @@ -24,7 +24,7 @@ export class CaslAbilityGuard implements CanActivate {
}

const ability = await this.authorizationService.defineAbilitiesFor(user);
throw new Error(`${ability}, ${subject}, ${requiredActions}`);
throw new InternalServerErrorException({ message: `${ability}, ${subject}, ${requiredActions}` });
return requiredActions.every((action) => ability.can(action, subject === "SELF" ? "USER" : subject));
}
}

0 comments on commit 7646b1e

Please sign in to comment.