diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-12-10 22:43:58 +0100 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-12-10 22:43:58 +0100 |
commit | a58261c0001cd4fef0f3683e0adfe862bf7d1ce5 (patch) | |
tree | 2147d85358469df5b47ab12d04014e993fc759b6 /src/app/open-id.service.ts | |
parent | fe974b7f0e15d041ce551a82b289ac2e65c0fd03 (diff) | |
download | reclaim-ui-a58261c0001cd4fef0f3683e0adfe862bf7d1ce5.tar.gz reclaim-ui-a58261c0001cd4fef0f3683e0adfe862bf7d1ce5.zip |
more refactoring and cleanup
Diffstat (limited to 'src/app/open-id.service.ts')
-rw-r--r-- | src/app/open-id.service.ts | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/app/open-id.service.ts b/src/app/open-id.service.ts index 0db9ee1..a090c32 100644 --- a/src/app/open-id.service.ts +++ b/src/app/open-id.service.ts | |||
@@ -4,18 +4,48 @@ import { HttpHeaders } from '@angular/common/http'; | |||
4 | import { Identity } from './identity'; | 4 | import { Identity } from './identity'; |
5 | import { ConfigService } from './config.service'; | 5 | import { ConfigService } from './config.service'; |
6 | import { Router } from '@angular/router'; | 6 | import { Router } from '@angular/router'; |
7 | import { GnsService } from './gns.service'; | ||
7 | 8 | ||
8 | @Injectable() | 9 | @Injectable() |
9 | export class OpenIdService { | 10 | export class OpenIdService { |
10 | params: any; | 11 | params: any; |
11 | inOidcFlow: Boolean; | 12 | inOidcFlow: Boolean; |
13 | clientNameVerified: Boolean; | ||
14 | clientName: String; | ||
12 | 15 | ||
13 | constructor(private http: HttpClient, | 16 | constructor(private http: HttpClient, |
14 | private config: ConfigService, | 17 | private config: ConfigService, |
18 | private gnsService: GnsService, | ||
15 | private router: Router) { | 19 | private router: Router) { |
16 | this.params = {}; | 20 | this.params = {}; |
17 | this.inOidcFlow = false; | 21 | this.inOidcFlow = false; |
18 | } | 22 | } |
23 | |||
24 | getClientName() { | ||
25 | this.clientNameVerified = undefined; | ||
26 | if (!this.inOpenIdFlow()) { | ||
27 | return; | ||
28 | } | ||
29 | this.gnsService.getClientName(this.getClientId()) | ||
30 | .subscribe(record => { | ||
31 | const records = record.data; | ||
32 | console.log(records); | ||
33 | for (let i = 0; i < records.length; i++) { | ||
34 | if (records[i].record_type !== 'RECLAIM_OIDC_CLIENT') { | ||
35 | continue; | ||
36 | } | ||
37 | this.clientName = records[i].value; | ||
38 | this.clientNameVerified = true; | ||
39 | return; | ||
40 | } | ||
41 | this.clientNameVerified = false; | ||
42 | }, err => { | ||
43 | console.log(err); | ||
44 | this.clientNameVerified = false; | ||
45 | }); | ||
46 | } | ||
47 | |||
48 | isClientVerified() { return this.clientNameVerified; } | ||
19 | 49 | ||
20 | login(identity: Identity) { | 50 | login(identity: Identity) { |
21 | const httpOptions = { | 51 | const httpOptions = { |