| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 1 | /* |
| 2 | Copyright 2020 TATA ELXSI |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the 'License'); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | |
| 16 | Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in) |
| 17 | */ |
| 18 | |
| 19 | /** |
| 20 | * @file Auth gaurd |
| 21 | */ |
| 22 | import { Injectable } from '@angular/core'; |
| 23 | import { CanLoad, Route } from '@angular/router'; |
| 24 | import { Observable } from 'rxjs'; |
| 25 | |
| 26 | /** |
| 27 | * An Injectable is a class adorned with the @Injectable decorator function. |
| 28 | * @Injectable takes a metadata object that tells Angular how to compile and run module code |
| 29 | */ |
| 30 | @Injectable() |
| 31 | export class AcessGuardService implements CanLoad { |
| 32 | /** |
| 33 | * check if module can be loaded |
| 34 | */ |
| 35 | public canLoad(route: Route): Observable<boolean> | Promise<boolean> | boolean { |
| 36 | // Need to get the Role and valid here for authorization |
| SANDHYA.JS | dc7a661 | 2023-05-10 23:01:35 +0530 | [diff] [blame] | 37 | if (sessionStorage.getItem('role') === 'Admin') { |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 38 | return true; |
| 39 | } else { |
| 40 | return false; |
| 41 | } |
| 42 | } |
| 43 | } |