diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-12-10 20:08:57 +0100 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-12-10 20:08:57 +0100 |
commit | 06a374032147df1112b221d70d2acde92e65ee11 (patch) | |
tree | 5834c7315878f41b8cddd8111c5973e2bb525f37 | |
parent | ba87ca8eaef080f9d6acf29aae587711fc075a63 (diff) | |
download | reclaim-ui-06a374032147df1112b221d70d2acde92e65ee11.tar.gz reclaim-ui-06a374032147df1112b221d70d2acde92e65ee11.zip |
more refactoring
-rw-r--r-- | src/app/app-routing.module.ts | 8 | ||||
-rw-r--r-- | src/app/app.module.ts | 4 | ||||
-rw-r--r-- | src/app/authorization-request/authorization-request.component.css | 0 | ||||
-rw-r--r-- | src/app/authorization-request/authorization-request.component.html | 40 | ||||
-rw-r--r-- | src/app/authorization-request/authorization-request.component.ts | 59 | ||||
-rw-r--r-- | src/app/identity-list/identity-list.component.html | 45 | ||||
-rw-r--r-- | src/app/identity-list/identity-list.component.ts | 57 | ||||
-rw-r--r-- | src/styles.scss | 2 |
8 files changed, 112 insertions, 103 deletions
diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 30f732c..9019e84 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts | |||
@@ -3,17 +3,19 @@ import { RouterModule, Routes } from '@angular/router'; | |||
3 | import { IdentityListComponent } from './identity-list/identity-list.component'; | 3 | import { IdentityListComponent } from './identity-list/identity-list.component'; |
4 | import { NewIdentityComponent } from './new-identity/new-identity.component'; | 4 | import { NewIdentityComponent } from './new-identity/new-identity.component'; |
5 | import { EditIdentityComponent } from './edit-identity/edit-identity.component'; | 5 | import { EditIdentityComponent } from './edit-identity/edit-identity.component'; |
6 | import { AuthorizationRequestComponent } from './authorization-request/authorization-request.component'; | ||
6 | 7 | ||
7 | const routes: Routes = [ | 8 | const routes: Routes = [ |
8 | { path: 'index.html', component: IdentityListComponent }, | 9 | { path: '', component: IdentityListComponent }, |
9 | // { path: 'identities', component: IdentityListComponent }, | 10 | // { path: 'identities', component: IdentityListComponent }, |
10 | { path: '', redirectTo: '/index.html', pathMatch: 'full' }, | 11 | //{ path: '', redirectTo: '/index.html', pathMatch: 'full' }, |
11 | { path: 'new-identity', component: NewIdentityComponent }, | 12 | { path: 'new-identity', component: NewIdentityComponent }, |
12 | { path: 'edit-identity/:id', component: EditIdentityComponent }, | 13 | { path: 'edit-identity/:id', component: EditIdentityComponent }, |
14 | { path: 'authorization-request', component: AuthorizationRequestComponent } | ||
13 | ]; | 15 | ]; |
14 | 16 | ||
15 | @NgModule({ | 17 | @NgModule({ |
16 | imports: [RouterModule.forRoot(routes, { useHash: false })], | 18 | imports: [RouterModule.forRoot(routes, { useHash: true })], |
17 | exports: [RouterModule] | 19 | exports: [RouterModule] |
18 | }) | 20 | }) |
19 | export class AppRoutingModule { } | 21 | export class AppRoutingModule { } |
diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 77d4efb..d1c8b7a 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts | |||
@@ -17,6 +17,7 @@ import { SearchPipe } from './search.pipe'; | |||
17 | import { OpenIdService } from './open-id.service'; | 17 | import { OpenIdService } from './open-id.service'; |
18 | import { NewIdentityComponent } from './new-identity/new-identity.component'; | 18 | import { NewIdentityComponent } from './new-identity/new-identity.component'; |
19 | import { EditIdentityComponent } from './edit-identity/edit-identity.component'; | 19 | import { EditIdentityComponent } from './edit-identity/edit-identity.component'; |
20 | import { AuthorizationRequestComponent } from './authorization-request/authorization-request.component'; | ||
20 | 21 | ||
21 | @NgModule({ | 22 | @NgModule({ |
22 | declarations: [ | 23 | declarations: [ |
@@ -25,7 +26,8 @@ import { EditIdentityComponent } from './edit-identity/edit-identity.component'; | |||
25 | ModalComponent, | 26 | ModalComponent, |
26 | SearchPipe, | 27 | SearchPipe, |
27 | NewIdentityComponent, | 28 | NewIdentityComponent, |
28 | EditIdentityComponent | 29 | EditIdentityComponent, |
30 | AuthorizationRequestComponent | ||
29 | ], | 31 | ], |
30 | imports: [ | 32 | imports: [ |
31 | BrowserModule, | 33 | BrowserModule, |
diff --git a/src/app/authorization-request/authorization-request.component.css b/src/app/authorization-request/authorization-request.component.css new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/app/authorization-request/authorization-request.component.css | |||
diff --git a/src/app/authorization-request/authorization-request.component.html b/src/app/authorization-request/authorization-request.component.html new file mode 100644 index 0000000..e323603 --- /dev/null +++ b/src/app/authorization-request/authorization-request.component.html | |||
@@ -0,0 +1,40 @@ | |||
1 | <div style="text-align: center;"> | ||
2 | <span *ngIf="clientNameFound === undefined"> | ||
3 | <i class="fa fa-2x fa-circle-o-notch fa-spin fa-fw"></i> | ||
4 | <b class="fa-2x"> Verifying request, please stand by...</b> | ||
5 | </span> | ||
6 | <span *ngIf="clientNameFound"> | ||
7 | <i class="fa fa-2x fa-openid"></i> | ||
8 | <b class="fa-2x"> Authorization Request </b> | ||
9 | </span> | ||
10 | <span *ngIf="clientNameFound !== undefined && !clientNameFound"> | ||
11 | <b class="fa-2x"> Authorization failed. </b> | ||
12 | </span> | ||
13 | <br/> | ||
14 | </div> | ||
15 | <div *ngIf="clientNameFound"><strong>"{{ clientName }}"</strong> | ||
16 | asks you to share personal information.<br/> | ||
17 | Choose an identity to let it access the following information: | ||
18 | </div> | ||
19 | <ul *ngIf="clientNameFound"> | ||
20 | <li *ngFor="let attribute of getScopes()"><strong>{{attribute}}</strong> | ||
21 | </ul> | ||
22 | <div *ngIf="clientNameFound" style="text-align: center;"> | ||
23 | <button class="btn btn-danger m-1 mt-4" *ngIf="clientNameFound" (click)="cancelRequest()" style="margin-bottom: -4%;"> | ||
24 | <span class="fa fa-ban"></span> Decline | ||
25 | </button> | ||
26 | <button class="btn btn-primary m-1 mt-4" *ngIf="clientNameFound" (click)="closeModal('OpenIdInfo');"> | ||
27 | <span class="fa fa-arrow-circle-right"></span> Select identity... | ||
28 | </button> | ||
29 | </div> | ||
30 | <div *ngIf="clientNameFound !== undefined && !clientNameFound" style="text-align: center;"> | ||
31 | <button class="btn btn-primary mt-4" *ngIf="!clientNameFound" (click)="getClientName();"> | ||
32 | <span class="fa fa-openid"></span> Retry | ||
33 | </button> | ||
34 | </div> | ||
35 | <div *ngIf="clientNameFound === undefined" style="text-align: center;"> | ||
36 | <button class="btn btn-danger mt-4" *ngIf="clientNameFound === undefined" (click)="cancelRequest()"> | ||
37 | <span class="fa fa-ban"></span> Cancel verification request | ||
38 | </button> | ||
39 | </div> | ||
40 | |||
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 | } | ||
diff --git a/src/app/identity-list/identity-list.component.html b/src/app/identity-list/identity-list.component.html index bca97b5..7edb1e8 100644 --- a/src/app/identity-list/identity-list.component.html +++ b/src/app/identity-list/identity-list.component.html | |||
@@ -1,48 +1,3 @@ | |||
1 | <!-- OpenId Authorization Screen --> | ||
2 | <oid-modal id="OpenIdInfo"> | ||
3 | <div style="text-align: center;"> | ||
4 | <div class="logo"><img src="assets/reclaim_icon.png"/></div> | ||
5 | <hr> | ||
6 | <span *ngIf="clientNameFound === undefined"> | ||
7 | <i class="fa fa-2x fa-circle-o-notch fa-spin fa-fw"></i> | ||
8 | <b class="fa-2x"> Verifying request, please stand by...</b> | ||
9 | </span> | ||
10 | <span *ngIf="clientNameFound"> | ||
11 | <i class="fa fa-2x fa-openid"></i> | ||
12 | <b class="fa-2x"> Authorization Request </b> | ||
13 | </span> | ||
14 | <span *ngIf="clientNameFound !== undefined && !clientNameFound"> | ||
15 | <b class="fa-2x"> Authorization failed. </b> | ||
16 | </span> | ||
17 | <br/> | ||
18 | </div> | ||
19 | <div *ngIf="clientNameFound"><strong>"{{ clientName }}"</strong> | ||
20 | asks you to share personal information.<br/> | ||
21 | Choose an identity to let it access the following information: | ||
22 | </div> | ||
23 | <ul *ngIf="clientNameFound"> | ||
24 | <li *ngFor="let attribute of getScopes()"><strong>{{attribute}}</strong> | ||
25 | </ul> | ||
26 | <div *ngIf="clientNameFound" style="text-align: center;"> | ||
27 | <button class="btn btn-danger m-1 mt-4" *ngIf="clientNameFound" (click)="cancelRequest(); closeModal('OpenIdInfo');" style="margin-bottom: -4%;"> | ||
28 | <span class="fa fa-ban"></span> Decline | ||
29 | </button> | ||
30 | <button class="btn btn-primary m-1 mt-4" *ngIf="clientNameFound" (click)="closeModal('OpenIdInfo');"> | ||
31 | <span class="fa fa-arrow-circle-right"></span> Select identity... | ||
32 | </button> | ||
33 | </div> | ||
34 | <div *ngIf="clientNameFound !== undefined && !clientNameFound" style="text-align: center;"> | ||
35 | <button class="btn btn-primary mt-4" *ngIf="!clientNameFound" (click)="getClientName();"> | ||
36 | <span class="fa fa-openid"></span> Retry | ||
37 | </button> | ||
38 | </div> | ||
39 | <div *ngIf="clientNameFound === undefined" style="text-align: center;"> | ||
40 | <button class="btn btn-danger mt-4" *ngIf="clientNameFound === undefined" (click)="cancelRequest(); closeModal('OpenIdInfo');"> | ||
41 | <span class="fa fa-ban"></span> Cancel verification request | ||
42 | </button> | ||
43 | </div> | ||
44 | </oid-modal> | ||
45 | |||
46 | <!-- GNUnet not running --> | 1 | <!-- GNUnet not running --> |
47 | <oid-modal id="GnunetInfo"> | 2 | <oid-modal id="GnunetInfo"> |
48 | <div class="logo"><img src="assets/reclaim_icon.png"/></div> | 3 | <div class="logo"><img src="assets/reclaim_icon.png"/></div> |
diff --git a/src/app/identity-list/identity-list.component.ts b/src/app/identity-list/identity-list.component.ts index 17f1da4..b4971a3 100644 --- a/src/app/identity-list/identity-list.component.ts +++ b/src/app/identity-list/identity-list.component.ts | |||
@@ -55,8 +55,10 @@ export class IdentityListComponent implements OnInit { | |||
55 | this.modalOpened = false; | 55 | this.modalOpened = false; |
56 | if (!this.oidcService.inOpenIdFlow()) { | 56 | if (!this.oidcService.inOpenIdFlow()) { |
57 | this.oidcService.parseRouteParams(this.route.snapshot.queryParams); | 57 | this.oidcService.parseRouteParams(this.route.snapshot.queryParams); |
58 | if (this.oidcService.inOpenIdFlow()) { | ||
59 | this.router.navigate(['/authorization-request']); | ||
60 | } | ||
58 | } | 61 | } |
59 | this.getClientName(); | ||
60 | this.identityNameMapper = {}; | 62 | this.identityNameMapper = {}; |
61 | this.updateIdentities(); | 63 | this.updateIdentities(); |
62 | this.errorInfos = []; | 64 | this.errorInfos = []; |
@@ -68,47 +70,6 @@ export class IdentityListComponent implements OnInit { | |||
68 | 70 | ||
69 | hideConfirmDelete() { this.showConfirmDelete = null; } | 71 | hideConfirmDelete() { this.showConfirmDelete = null; } |
70 | 72 | ||
71 | getClientName() { | ||
72 | this.clientNameFound = undefined; | ||
73 | this.clientName = this.oidcService.getClientId(); | ||
74 | if (!this.oidcService.inOpenIdFlow()) { | ||
75 | return; | ||
76 | } | ||
77 | this.gnsService.getClientName(this.oidcService.getClientId()) | ||
78 | .subscribe(record => { | ||
79 | const records = record.data; | ||
80 | console.log(records); | ||
81 | for (let i = 0; i < records.length; i++) { | ||
82 | if (records[i].record_type !== 'RECLAIM_OIDC_CLIENT') { | ||
83 | continue; | ||
84 | } | ||
85 | this.clientName = records[i].value; | ||
86 | this.clientNameFound = true; | ||
87 | return; | ||
88 | } | ||
89 | this.clientNameFound = false; | ||
90 | }, err => { | ||
91 | console.log(err); | ||
92 | this.clientNameFound = false; | ||
93 | }); | ||
94 | } | ||
95 | |||
96 | intToRGB(i) { | ||
97 | i = this.hashCode(i); | ||
98 | const c = (i & 0x00FFFFFF).toString(16).toUpperCase(); | ||
99 | |||
100 | return '#' + | ||
101 | '00000'.substring(0, 6 - c.length) + c; | ||
102 | } | ||
103 | |||
104 | hashCode(str) { | ||
105 | let hash = 0; | ||
106 | for (let i = 0; i < str.length; i++) { | ||
107 | hash = str.charCodeAt(i) + ((hash << 5) - hash); | ||
108 | } | ||
109 | return hash; | ||
110 | } | ||
111 | |||
112 | getMissingAttributes(identity) { | 73 | getMissingAttributes(identity) { |
113 | const scopes = this.getScopes(); | 74 | const scopes = this.getScopes(); |
114 | let i; | 75 | let i; |
@@ -164,18 +125,6 @@ export class IdentityListComponent implements OnInit { | |||
164 | }); | 125 | }); |
165 | } | 126 | } |
166 | 127 | ||
167 | cancelRequest() { | ||
168 | this.closeModal('OpenIdInfo'); | ||
169 | this.modalOpened = false; | ||
170 | this.oidcService.cancelAuthorization().subscribe(() => { | ||
171 | console.log('Request cancelled'); | ||
172 | this.requestedAttributes = {}; | ||
173 | this.missingAttributes = {}; | ||
174 | this.router.navigate(['/']); | ||
175 | //Manually reset this component | ||
176 | }); | ||
177 | } | ||
178 | |||
179 | loginIdentity(identity) { | 128 | loginIdentity(identity) { |
180 | this.oidcService.login(identity).subscribe(() => { | 129 | this.oidcService.login(identity).subscribe(() => { |
181 | console.log('Successfully logged in'); | 130 | console.log('Successfully logged in'); |
diff --git a/src/styles.scss b/src/styles.scss index d76e90c..a1c43dd 100644 --- a/src/styles.scss +++ b/src/styles.scss | |||
@@ -113,6 +113,8 @@ div.card-avatar-id { | |||
113 | .card-avatar .btn-primary:hover { | 113 | .card-avatar .btn-primary:hover { |
114 | background-image: none; | 114 | background-image: none; |
115 | color: #444; | 115 | color: #444; |
116 | border: none; | ||
117 | box-shadow: none; | ||
116 | background-color: #eee; | 118 | background-color: #eee; |
117 | } | 119 | } |
118 | 120 | ||