Last change
on this file since 6fe77af was 84d0fbb, checked in by Ema <ema_spirova@…>, 3 years ago |
spring security 2.0
|
-
Property mode
set to
100644
|
File size:
552 bytes
|
Line | |
---|
1 | import { Injectable } from '@angular/core';
|
---|
2 | import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree } from '@angular/router';
|
---|
3 | import { Observable } from 'rxjs';
|
---|
4 |
|
---|
5 | @Injectable({
|
---|
6 | providedIn: 'root'
|
---|
7 | })
|
---|
8 | export class AuthGuard implements CanActivate {
|
---|
9 |
|
---|
10 | constructor(private router : Router){}
|
---|
11 | canActivate(
|
---|
12 | route: ActivatedRouteSnapshot,
|
---|
13 | state: RouterStateSnapshot): boolean{
|
---|
14 |
|
---|
15 | if(localStorage.getItem('token') != null)
|
---|
16 | return true;
|
---|
17 | this.router.navigate(['planners']);
|
---|
18 | return false;
|
---|
19 | }
|
---|
20 |
|
---|
21 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.