-
Notifications
You must be signed in to change notification settings - Fork 208
/
app.component.ts
70 lines (56 loc) · 2.17 KB
/
app.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import {
OidcClientNotification,
OidcSecurityService,
} from './auth/angular-auth-oidc-client';
import { ConfigAuthenticatedResult } from './auth/authState/auth-result';
import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import { LocaleService, TranslationService, Language } from 'angular-l10n';
import './app.component.css';
@Component({
selector: 'app-component',
templateUrl: 'app.component.html',
})
export class AppComponent implements OnInit {
@Language() lang = '';
title = '';
userDataChanged$: Observable<OidcClientNotification<any>>;
userData$: Observable<any>;
isAuthenticated$: Observable<boolean | ConfigAuthenticatedResult[]>;
checkSessionChanged$: Observable<boolean>;
checkSessionChanged: any;
constructor(
public oidcSecurityService: OidcSecurityService,
public locale: LocaleService,
public translation: TranslationService
) {
console.log('AppComponent STARTING');
}
ngOnInit() {
this.userData$ = this.oidcSecurityService.userData$;
this.isAuthenticated$ = this.oidcSecurityService.isAuthenticated$;
this.checkSessionChanged$ = this.oidcSecurityService.checkSessionChanged$;
this.oidcSecurityService.checkAuth().subscribe((isAuthenticated) => console.log('app authenticated', isAuthenticated));
}
changeCulture(language: string, country: string) {
this.locale.setDefaultLocale(language, country);
console.log('set language: ' + language);
}
login() {
console.log('start login');
let culture = 'de-CH';
if (this.locale.getCurrentCountry()) {
culture = this.locale.getCurrentLanguage() + '-' + this.locale.getCurrentCountry();
}
console.log(culture);
this.oidcSecurityService.authorize(null, { customParams: { 'ui_locales': culture } });
}
refreshSession() {
console.log('start refreshSession');
this.oidcSecurityService.authorize();
}
logout() {
console.log('start logoff');
this.oidcSecurityService.logoff();
}
}