diff options
Diffstat (limited to 'src/app/authorization-request/authorization-request.component.ts')
-rw-r--r-- | src/app/authorization-request/authorization-request.component.ts | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/app/authorization-request/authorization-request.component.ts b/src/app/authorization-request/authorization-request.component.ts new file mode 100644 index 0000000..96353f1 --- /dev/null +++ b/src/app/authorization-request/authorization-request.component.ts | |||
@@ -0,0 +1,59 @@ | |||
1 | import { Component, OnInit } from '@angular/core'; | ||
2 | import { Router } from '@angular/router'; | ||
3 | import { OpenIdService } from '../open-id.service'; | ||
4 | import { GnsService } from '../gns.service'; | ||
5 | |||
6 | @Component({ | ||
7 | selector: 'app-authorization-request', | ||
8 | templateUrl: './authorization-request.component.html', | ||
9 | styleUrls: ['./authorization-request.component.css'] | ||
10 | }) | ||
11 | export class AuthorizationRequestComponent implements OnInit { | ||
12 | clientNameFound: Boolean; | ||
13 | clientName: String; | ||
14 | |||
15 | constructor(private oidcService: OpenIdService, | ||
16 | private gnsService: GnsService, | ||
17 | private router: Router) { } | ||
18 | |||
19 | ngOnInit() { | ||
20 | this.clientNameFound = false; | ||
21 | this.clientName = '-'; | ||
22 | this.getClientName(); | ||
23 | } | ||
24 | |||
25 | getClientName() { | ||
26 | this.clientNameFound = undefined; | ||
27 | this.clientName = this.oidcService.getClientId(); | ||
28 | if (!this.oidcService.inOpenIdFlow()) { | ||
29 | return; | ||
30 | } | ||
31 | this.gnsService.getClientName(this.oidcService.getClientId()) | ||
32 | .subscribe(record => { | ||
33 | const records = record.data; | ||
34 | console.log(records); | ||
35 | for (let i = 0; i < records.length; i++) { | ||
36 | if (records[i].record_type !== 'RECLAIM_OIDC_CLIENT') { | ||
37 | continue; | ||
38 | } | ||
39 | this.clientName = records[i].value; | ||
40 | this.clientNameFound = true; | ||
41 | return; | ||
42 | } | ||
43 | this.clientNameFound = false; | ||
44 | }, err => { | ||
45 | console.log(err); | ||
46 | this.clientNameFound = false; | ||
47 | }); | ||
48 | } | ||
49 | |||
50 | cancelRequest() { | ||
51 | this.oidcService.cancelAuthorization().subscribe(() => { | ||
52 | console.log('Request cancelled'); | ||
53 | this.router.navigate(['/']); | ||
54 | //Manually reset this component | ||
55 | }); | ||
56 | } | ||
57 | |||
58 | |||
59 | } | ||