-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathhome.component.ts
75 lines (61 loc) · 1.58 KB
/
home.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
71
72
73
74
75
import { Component } from '@angular/core';
import {
AuthService,
AuthorizeEndpointSilentClientService,
AuthorizeEndpointPopupClientService
} from 'angular-simple-oidc';
import { map } from 'rxjs/operators';
@Component({
selector: 'soidc-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.css']
})
export class HomeComponent {
public get identityTokenDecoded$() {
return this.auth.identityTokenDecoded$;
}
public get identityToken$() {
return this.auth.identityToken$;
}
public get accessToken$() {
return this.auth.accessToken$;
}
public get refreshToken$() {
return this.auth.refreshToken$;
}
public get isLoggedIn$() {
return this.auth.isLoggedIn$;
}
public profile$ = this.auth.userInfo$;
public get accessTokenExpiration$() {
return this.auth.tokenExpiration$
.pipe(
map(time => new Date(time))
);
}
constructor(
private readonly auth: AuthService,
private readonly authorizeSilentClient: AuthorizeEndpointSilentClientService,
private readonly authorizePopupClient: AuthorizeEndpointPopupClientService,
) { }
public doTokenRefresh() {
this.auth.refreshAccessToken()
.subscribe();
}
public endSession() {
this.auth.endSession()
.subscribe();
}
public doCodeFlowInIframe() {
this.authorizeSilentClient.startCodeFlowInIframe()
.subscribe();
}
public doAuthorizeWithRedirect() {
this.auth.startCodeFlow()
.subscribe();
}
public doLoginInPopup() {
this.authorizePopupClient.startCodeFlowInPopup()
.subscribe();
}
}