1 |
1c220966
|
Hung Hoang
|
import {Router} from '@angular/router';
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* Base class for all guards, provides navigating users to
|
5 |
|
|
* components
|
6 |
|
|
*/
|
7 |
|
|
export class BaseGuard {
|
8 |
|
|
constructor(protected router: Router) {
|
9 |
|
|
|
10 |
|
|
}
|
11 |
|
|
|
12 |
|
|
protected navigateUserToLogin(): boolean {
|
13 |
|
|
console.log('Navigating user to login');
|
14 |
|
|
this.router.navigate(['/login']);
|
15 |
|
|
|
16 |
|
|
return false;
|
17 |
|
|
}
|
18 |
|
|
|
19 |
|
|
protected navigateUserToDashboard(): boolean {
|
20 |
|
|
console.log('Navigating user to dashboard');
|
21 |
|
|
this.router.navigate(['/dashboard']);
|
22 |
|
|
|
23 |
|
|
return false;
|
24 |
|
|
}
|
25 |
|
|
|
26 |
|
|
protected navigateUserTo(component: string): boolean {
|
27 |
|
|
this.router.navigate([component]);
|
28 |
|
|
|
29 |
|
|
return false;
|
30 |
|
|
}
|
31 |
|
|
}
|