Skip to content

Commit

Permalink
hotfix for guard injector scope
Browse files Browse the repository at this point in the history
  • Loading branch information
MetinSeylan committed Nov 20, 2021
1 parent d22a890 commit 44780d7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
7 changes: 5 additions & 2 deletions dist/Trace/Injectors/GuardInjector.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/Trace/Injectors/GuardInjector.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/tsconfig.build.tsbuildinfo

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions src/Trace/Injectors/GuardInjector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ export class GuardInjector extends BaseTraceInjector implements Injector {
const guards = this.getGuards(controller.metatype).map((guard) => {
const prototype = guard['prototype'] ?? guard;
const traceName = `Guard->${controller.name}.${prototype.constructor.name}`;
guard.canActivate = this.wrap(prototype.canActivate, traceName, {
prototype.canActivate = this.wrap(prototype.canActivate, traceName, {
controller: controller.name,
guard: prototype.constructor.name,
scope: 'CONTROLLER',
});
Object.assign(prototype, this);
this.loggerService.log(`Mapped ${traceName}`, this.constructor.name);
return guard;
});
Expand All @@ -44,12 +45,13 @@ export class GuardInjector extends BaseTraceInjector implements Injector {
(guard) => {
const prototype = guard['prototype'] ?? guard;
const traceName = `Guard->${controller.name}.${controller.metatype.prototype[key].name}.${prototype.constructor.name}`;
guard.canActivate = this.wrap(prototype.canActivate, traceName, {
prototype.canActivate = this.wrap(prototype.canActivate, traceName, {
controller: controller.name,
guard: prototype.constructor.name,
method: controller.metatype.prototype[key].name,
scope: 'CONTROLLER_METHOD',
});
Object.assign(prototype, this);
this.loggerService.log(
`Mapped ${traceName}`,
this.constructor.name,
Expand Down Expand Up @@ -90,6 +92,7 @@ export class GuardInjector extends BaseTraceInjector implements Injector {
scope: 'GLOBAL',
},
);
Object.assign(provider.metatype.prototype, this);
this.loggerService.log(`Mapped ${traceName}`, this.constructor.name);
}
}
Expand Down

0 comments on commit 44780d7

Please sign in to comment.