iwa23-4 2 лет назад
Родитель
Сommit
250d7cb563

+ 0 - 4
frontend/.vscode/extensions.json

@@ -1,4 +0,0 @@
-{
-  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
-  "recommendations": ["angular.ng-template"]
-}

+ 0 - 42
frontend/.vscode/tasks.json

@@ -1,42 +0,0 @@
-{
-  // For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
-  "version": "2.0.0",
-  "tasks": [
-    {
-      "type": "npm",
-      "script": "start",
-      "isBackground": true,
-      "problemMatcher": {
-        "owner": "typescript",
-        "pattern": "$tsc",
-        "background": {
-          "activeOnStart": true,
-          "beginsPattern": {
-            "regexp": "(.*?)"
-          },
-          "endsPattern": {
-            "regexp": "bundle generation complete"
-          }
-        }
-      }
-    },
-    {
-      "type": "npm",
-      "script": "test",
-      "isBackground": true,
-      "problemMatcher": {
-        "owner": "typescript",
-        "pattern": "$tsc",
-        "background": {
-          "activeOnStart": true,
-          "beginsPattern": {
-            "regexp": "(.*?)"
-          },
-          "endsPattern": {
-            "regexp": "bundle generation complete"
-          }
-        }
-      }
-    }
-  ]
-}

+ 0 - 16
frontend/src/app/guards/role.guard.spec.ts

@@ -1,16 +0,0 @@
-import { TestBed } from '@angular/core/testing';
-
-import { RoleGuard } from './role.guard';
-
-describe('RoleGuard', () => {
-  let guard: RoleGuard;
-
-  beforeEach(() => {
-    TestBed.configureTestingModule({});
-    guard = TestBed.inject(RoleGuard);
-  });
-
-  it('should be created', () => {
-    expect(guard).toBeTruthy();
-  });
-});

+ 0 - 31
frontend/src/app/guards/role.guard.ts

@@ -1,31 +0,0 @@
-import { Injectable } from '@angular/core';
-import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree} from '@angular/router';
-import { Observable } from 'rxjs';
-import {TokenStorageService} from "../auth/token-storage.service";
-
-@Injectable({
-  providedIn: 'root'
-})
-export class RoleGuard implements CanActivate {
-
-  constructor(private tokenStorageService: TokenStorageService, private router: Router) {
-  }
-
-  canActivate(
-    route: ActivatedRouteSnapshot,
-    state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
-
-    // check if any role from authorities list is in the routing list defined
-    for (let i = 0; i < route.data['roles'].length; i++) {
-      for (let j = 0; j < this.tokenStorageService.getAuthorities().length; j++) {
-        if (route.data['roles'][i] === this.tokenStorageService.getAuthorities()[j]) {
-          return true;
-        }
-      }
-    }
-
-    // otherwise redirect to specified url
-    this.router.navigateByUrl('').then();
-    return false;
-  }
-}