39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
import {Component, Input, OnInit} from '@angular/core';
|
|
import {environment} from '../../../environments/environment';
|
|
import {AuthService} from '../../services/auth.service';
|
|
|
|
@Component({
|
|
selector: 'app-navigation',
|
|
templateUrl: './navigation.component.html',
|
|
styleUrls: ['./navigation.component.css']
|
|
})
|
|
export class NavigationComponent implements OnInit {
|
|
|
|
openid_endpoint: string = environment.openid_endpoint;
|
|
title: string = environment.title;
|
|
|
|
is_Authenticated = false;
|
|
|
|
@Input() activeLink: string;
|
|
|
|
constructor(public authService: AuthService) {
|
|
this.is_Authenticated = authService.isAuthenticated();
|
|
}
|
|
|
|
ngOnInit(): void {
|
|
}
|
|
|
|
logout() {
|
|
const token = this.authService.getToken();
|
|
let url = this.openid_endpoint + '/logout' +
|
|
'?post_logout_redirect_uri=' + environment.location;
|
|
if (token) {
|
|
url += '&id_token_hint=' + this.authService.getToken();
|
|
}
|
|
this.authService.deleteToken();
|
|
this.is_Authenticated = false;
|
|
window.location.replace(url);
|
|
}
|
|
|
|
}
|