Revision 51194
Added by Myrto Koukouli over 6 years ago
auth-guard.service.ts | ||
---|---|---|
2 | 2 |
import {Injectable} from '@angular/core'; |
3 | 3 |
import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot} from '@angular/router'; |
4 | 4 |
import {AuthenticationService} from './authentication.service'; |
5 |
import { getCookie } from '../domain/utils'; |
|
6 |
import { loginUrl } from "../domain/tempAPI"; |
|
5 | 7 |
|
6 | 8 |
@Injectable () |
7 | 9 |
export class AuthGuardService implements CanActivate { |
8 | 10 |
|
9 |
private oidc_endpoint : string = process.env.OIDC_ENDPOINT; |
|
11 |
// private oidc_endpoint : string = process.env.OIDC_ENDPOINT; |
|
12 |
private loginUrl : string = loginUrl; |
|
10 | 13 |
|
11 | 14 |
constructor(private authenticationService: AuthenticationService, private router: Router) {} |
12 | 15 |
|
13 | 16 |
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { |
14 | 17 |
|
15 | 18 |
if (this.authenticationService.isLoggedIn) { return true; } |
16 |
//if (getCookie('name') != null) return true; |
|
19 |
|
|
20 |
if (getCookie('currentUser') != null) {return true;} |
|
21 |
|
|
17 | 22 |
// Store the attempted URL for redirecting |
18 | 23 |
sessionStorage.setItem("state.location",state.url); |
19 | 24 |
// Navigate to the login page |
20 |
//window.location.href = this.oidc_endpoint;
|
|
25 |
window.location.href = this.loginUrl;
|
|
21 | 26 |
|
22 |
window.location.href = '/home'; |
|
23 |
|
|
24 | 27 |
return false; |
25 | 28 |
} |
26 | 29 |
} |
Also available in: Unified diff
almost finished login