From b2e2f9e77becdfdab88f1f2fe04906ba3e9590a8 Mon Sep 17 00:00:00 2001 From: Erik Surface Date: Fri, 10 Jan 2025 15:24:06 -0500 Subject: [PATCH] Remove auth directives from online-survey-app --- .../has-a-permission.directive.spec.ts | 8 ----- .../_directives/has-a-permission.directive.ts | 31 ------------------- .../has-all-permissions.directive.spec.ts | 8 ----- .../has-all-permissions.directive.ts | 29 ----------------- .../has-some-permissions.directive.spec.ts | 8 ----- .../has-some-permissions.directive.ts | 31 ------------------- 6 files changed, 115 deletions(-) delete mode 100644 online-survey-app/src/app/core/auth/_directives/has-a-permission.directive.spec.ts delete mode 100644 online-survey-app/src/app/core/auth/_directives/has-a-permission.directive.ts delete mode 100644 online-survey-app/src/app/core/auth/_directives/has-all-permissions.directive.spec.ts delete mode 100644 online-survey-app/src/app/core/auth/_directives/has-all-permissions.directive.ts delete mode 100644 online-survey-app/src/app/core/auth/_directives/has-some-permissions.directive.spec.ts delete mode 100644 online-survey-app/src/app/core/auth/_directives/has-some-permissions.directive.ts diff --git a/online-survey-app/src/app/core/auth/_directives/has-a-permission.directive.spec.ts b/online-survey-app/src/app/core/auth/_directives/has-a-permission.directive.spec.ts deleted file mode 100644 index 403650b0ba..0000000000 --- a/online-survey-app/src/app/core/auth/_directives/has-a-permission.directive.spec.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { HasAPermissionDirective } from './has-a-permission.directive'; - -describe('HasAPermissionDirective', () => { - it('should create an instance', () => { - const directive = new HasAPermissionDirective(); - expect(directive).toBeTruthy(); - }); -}); diff --git a/online-survey-app/src/app/core/auth/_directives/has-a-permission.directive.ts b/online-survey-app/src/app/core/auth/_directives/has-a-permission.directive.ts deleted file mode 100644 index 1204beeb01..0000000000 --- a/online-survey-app/src/app/core/auth/_directives/has-a-permission.directive.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Directive, Input, TemplateRef, ViewContainerRef, OnInit } from '@angular/core'; -import { AuthenticationService } from '../_services/authentication.service'; - -@Directive({ - selector: '[appHasAPermission]' -}) -export class HasAPermissionDirective implements OnInit { - private _groupId; - private _permission; - @Input() - set appHasAPermissionGroup(value: string) { - this._groupId = value; - } - @Input() - set appHasAPermissionPermission(value: string[]) { - this._permission = value; - } - - constructor(private authenticationService: AuthenticationService, - private templateRef: TemplateRef, - private viewContainer: ViewContainerRef) { } - async ngOnInit() { - const isPermitted = await this.authenticationService.doesUserHaveAPermission(this._groupId, this._permission); - if (isPermitted) { - this.viewContainer.createEmbeddedView(this.templateRef); - } else { - this.viewContainer.clear(); - } - } - -} diff --git a/online-survey-app/src/app/core/auth/_directives/has-all-permissions.directive.spec.ts b/online-survey-app/src/app/core/auth/_directives/has-all-permissions.directive.spec.ts deleted file mode 100644 index 00447ee7b3..0000000000 --- a/online-survey-app/src/app/core/auth/_directives/has-all-permissions.directive.spec.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { HasAllPermissionsDirective } from './has-all-permissions.directive'; - -describe('HasAllPermissionsDirective', () => { - it('should create an instance', () => { - const directive = new HasAllPermissionsDirective(); - expect(directive).toBeTruthy(); - }); -}); diff --git a/online-survey-app/src/app/core/auth/_directives/has-all-permissions.directive.ts b/online-survey-app/src/app/core/auth/_directives/has-all-permissions.directive.ts deleted file mode 100644 index 4f19f18b07..0000000000 --- a/online-survey-app/src/app/core/auth/_directives/has-all-permissions.directive.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Directive, Input, AfterViewInit, TemplateRef, ViewContainerRef, OnInit } from '@angular/core'; -import { AuthenticationService } from '../_services/authentication.service'; -@Directive({ - selector: '[appHasAllPermissions]' -}) -export class HasAllPermissionsDirective implements OnInit { - private _groupId; - private _permissions; - @Input() - set appHasAllPermissionsGroup(value: string) { - this._groupId = value; - } - @Input() - set appHasAllPermissionsPermissions(value: string[]) { - this._permissions = value; - } - - constructor(private authenticationService: AuthenticationService, - private templateRef: TemplateRef, - private viewContainer: ViewContainerRef) { } - async ngOnInit() { - const isPermitted = await this.authenticationService.doesUserHaveAllPermissions(this._groupId, this._permissions); - if (isPermitted) { - this.viewContainer.createEmbeddedView(this.templateRef); - } else { - this.viewContainer.clear(); - } - } -} diff --git a/online-survey-app/src/app/core/auth/_directives/has-some-permissions.directive.spec.ts b/online-survey-app/src/app/core/auth/_directives/has-some-permissions.directive.spec.ts deleted file mode 100644 index 83187b8309..0000000000 --- a/online-survey-app/src/app/core/auth/_directives/has-some-permissions.directive.spec.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { HasSomePermissionsDirective } from './has-some-permissions.directive'; - -describe('HasSomePermissionsDirective', () => { - it('should create an instance', () => { - const directive = new HasSomePermissionsDirective(); - expect(directive).toBeTruthy(); - }); -}); diff --git a/online-survey-app/src/app/core/auth/_directives/has-some-permissions.directive.ts b/online-survey-app/src/app/core/auth/_directives/has-some-permissions.directive.ts deleted file mode 100644 index e1dcdbcd77..0000000000 --- a/online-survey-app/src/app/core/auth/_directives/has-some-permissions.directive.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Directive, Input, TemplateRef, ViewContainerRef, OnInit } from '@angular/core'; -import { AuthenticationService } from '../_services/authentication.service'; - -@Directive({ - selector: '[appHasSomePermissions]' -}) -export class HasSomePermissionsDirective implements OnInit { - private _groupId; - private _permissions; - @Input() - set appHasSomePermissionsGroup(value: string) { - this._groupId = value; - } - @Input() - set appHasSomePermissionsPermissions(value: string[]) { - this._permissions = value; - } - - constructor(private authenticationService: AuthenticationService, - private templateRef: TemplateRef, - private viewContainer: ViewContainerRef) { } - async ngOnInit() { - const isPermitted = await this.authenticationService.doesUserHaveSomePermissions(this._groupId, this._permissions); - if (isPermitted) { - this.viewContainer.createEmbeddedView(this.templateRef); - } else { - this.viewContainer.clear(); - } - } - -}