parameter-definition service- removed unused code
[appc/cdt.git] / src / app / vnfs / LoginGuardService / Login-guard-service.ts
1 /*
2 ============LICENSE_START==========================================
3 ===================================================================
4 Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
5
6 Copyright (C) 2018 IBM.
7 ===================================================================
8
9 Unless otherwise specified, all software contained herein is licensed
10 under the Apache License, Version 2.0 (the License);
11 you may not use this software except in compliance with the License.
12 You may obtain a copy of the License at
13
14     http://www.apache.org/licenses/LICENSE-2.0
15
16 Unless required by applicable law or agreed to in writing, software
17 distributed under the License is distributed on an "AS IS" BASIS,
18 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 See the License for the specific language governing permissions and
20 limitations under the License.
21 ============LICENSE_END============================================
22 */
23
24 import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot} from '@angular/router';
25
26 import {Injectable} from '@angular/core';
27
28 @Injectable()
29 export class LoginGuardService implements CanActivate {
30
31     constructor(private router: Router) {
32     }
33
34     canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
35
36         let userId = localStorage['userId'];
37         if (userId != null && userId != undefined && userId != '') {
38             return true;
39         } else {
40             this.router.navigate(['/vnfs/login'],{ queryParams: { returnUrl: state.url }});
41             return false;
42         }
43
44     }
45 }