[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[reclaim-ui] 167/459: more refactoring and cleanup
From: |
gnunet |
Subject: |
[reclaim-ui] 167/459: more refactoring and cleanup |
Date: |
Fri, 11 Jun 2021 23:24:19 +0200 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository reclaim-ui.
commit a58261c0001cd4fef0f3683e0adfe862bf7d1ce5
Author: Schanzenbach, Martin <mschanzenbach@posteo.de>
AuthorDate: Tue Dec 10 22:43:58 2019 +0100
more refactoring and cleanup
---
.../authorization-request.component.html | 18 +++++------
.../authorization-request.component.ts | 36 +++++-----------------
src/app/edit-identity/edit-identity.component.ts | 7 +++++
src/app/identity-list/identity-list.component.html | 8 ++---
src/app/identity-list/identity-list.component.ts | 25 ++++-----------
src/app/open-id.service.ts | 30 ++++++++++++++++++
6 files changed, 63 insertions(+), 61 deletions(-)
diff --git a/src/app/authorization-request/authorization-request.component.html
b/src/app/authorization-request/authorization-request.component.html
index 975e252..0adddbd 100644
--- a/src/app/authorization-request/authorization-request.component.html
+++ b/src/app/authorization-request/authorization-request.component.html
@@ -2,16 +2,16 @@
<i class="fa fa-2x fa-openid"></i>
<b class="fa-2x"> Authorization Request </b>
<br/>
- <span *ngIf="clientNameFound === undefined">
+ <span *ngIf="isClientVerified() === undefined">
<i class="fa fa-2x fa-circle-o-notch fa-spin fa-fw"></i>
<b class="fa-2x"> Verifying request, please stand by...</b>
</span>
- <span *ngIf="clientNameFound !== undefined && !clientNameFound">
+ <span *ngIf="isClientVerified() !== undefined && !isClientVerified()">
<b class="fa-2x"> Authorization failed. </b>
</span>
<br/>
</div>
-<div class="card" *ngIf="clientNameFound" style="margin-left:30%; width:40%;">
+<div class="card" *ngIf="isClientVerified()" style="margin-left:30%;
width:40%;">
<div class="card-body">
<strong>{{ clientName }}</strong>
asks you to share personal information.<br/>
@@ -21,21 +21,21 @@
</ul>
</div>
<div style="margin: 1em;">
- <button class="btn btn-danger m-1 mt-4" *ngIf="clientNameFound"
(click)="cancelRequest()" style="margin-bottom: -4%;">
+ <button class="btn btn-danger m-1 mt-4" *ngIf="isClientVerified()"
(click)="cancelRequest()" style="margin-bottom: -4%;">
<span class="fa fa-ban"></span> Decline
</button>
- <button class="btn btn-primary m-1 mt-4" [routerLink]="['/']"
*ngIf="clientNameFound">
+ <button class="btn btn-primary m-1 mt-4" [routerLink]="['/']"
*ngIf="isClientVerified()">
<span class="fa fa-arrow-circle-right"></span> Select identity...
</button>
</div>
</div>
-<div *ngIf="clientNameFound !== undefined && !clientNameFound"
style="text-align: center;">
- <button class="btn btn-primary mt-4" *ngIf="!clientNameFound"
(click)="getClientName();">
+<div *ngIf="isClientVerified() !== undefined && !isClientVerified()"
style="text-align: center;">
+ <button class="btn btn-primary mt-4" *ngIf="!isClientVerified()"
(click)="retryVerify();">
<span class="fa fa-openid"></span> Retry
</button>
</div>
-<div *ngIf="clientNameFound === undefined" style="text-align: center;">
- <button class="btn btn-danger mt-4" *ngIf="clientNameFound === undefined"
(click)="cancelRequest()">
+<div *ngIf="isClientVerified() === undefined" style="text-align: center;">
+ <button class="btn btn-danger mt-4" *ngIf="isClientVerified() === undefined"
(click)="cancelRequest()">
<span class="fa fa-ban"></span> Cancel verification request
</button>
</div>
diff --git a/src/app/authorization-request/authorization-request.component.ts
b/src/app/authorization-request/authorization-request.component.ts
index ddb1dc6..bd870e2 100644
--- a/src/app/authorization-request/authorization-request.component.ts
+++ b/src/app/authorization-request/authorization-request.component.ts
@@ -1,7 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { OpenIdService } from '../open-id.service';
-import { GnsService } from '../gns.service';
@Component({
selector: 'app-authorization-request',
@@ -9,48 +8,23 @@ import { GnsService } from '../gns.service';
styleUrls: ['./authorization-request.component.css']
})
export class AuthorizationRequestComponent implements OnInit {
- clientNameFound: Boolean;
clientName: String;
constructor(private oidcService: OpenIdService,
- private gnsService: GnsService,
private router: Router) { }
ngOnInit() {
- this.clientNameFound = false;
this.clientName = '-';
- this.getClientName();
}
getScopes() {
return this.oidcService.getScope();
}
- getClientName() {
- this.clientNameFound = undefined;
- this.clientName = this.oidcService.getClientId();
- if (!this.oidcService.inOpenIdFlow()) {
- return;
- }
- this.gnsService.getClientName(this.oidcService.getClientId())
- .subscribe(record => {
- const records = record.data;
- console.log(records);
- for (let i = 0; i < records.length; i++) {
- if (records[i].record_type !== 'RECLAIM_OIDC_CLIENT') {
- continue;
- }
- this.clientName = records[i].value;
- this.clientNameFound = true;
- return;
- }
- this.clientNameFound = false;
- }, err => {
- console.log(err);
- this.clientNameFound = false;
- });
+ isClientVerified() {
+ return this.oidcService.isClientVerified();
}
-
+
cancelRequest() {
this.oidcService.cancelAuthorization().subscribe(() => {
console.log('Request cancelled');
@@ -59,5 +33,9 @@ export class AuthorizationRequestComponent implements OnInit {
});
}
+ retryVerify() {
+ this.oidcService.getClientName();
+ }
+
}
diff --git a/src/app/edit-identity/edit-identity.component.ts
b/src/app/edit-identity/edit-identity.component.ts
index d438c0e..3adeb76 100644
--- a/src/app/edit-identity/edit-identity.component.ts
+++ b/src/app/edit-identity/edit-identity.component.ts
@@ -328,4 +328,11 @@ export class EditIdentityComponent implements OnInit {
this.requestedAttributes.length;
}
+ getAudienceName(ticket) {
+ if (undefined === this.audienceNames[ticket.audience]) {
+ return 'Unknown';
+ }
+ return this.audienceNames[ticket.audience];
+ }
+
}
diff --git a/src/app/identity-list/identity-list.component.html
b/src/app/identity-list/identity-list.component.html
index 7edb1e8..40e95ba 100644
--- a/src/app/identity-list/identity-list.component.html
+++ b/src/app/identity-list/identity-list.component.html
@@ -20,7 +20,7 @@
<!-- Cancel authorization -->
<div style="margin-bottom: 1em; text-align: center;">
- <button *ngIf="inOpenIdFlow() && clientNameFound" class="btn btn-danger
mt-2" (click)="cancelRequest()">
+ <button *ngIf="inOpenIdFlow()" class="btn btn-danger mt-2"
(click)="cancelRequest()">
<span class="fa fa-ban"></span> Decline authorization request
</button>
</div>
@@ -112,9 +112,9 @@
<div>
<div>
- <button *ngIf="canAuthorize(identity)" [disabled]="!inOpenIdFlow()
|| isAttributeMissing(identity) || !clientNameFound"
(click)="loginIdentity(identity)" class="btn btn-primary mr-1 openid-login">
- <span *ngIf="clientNameFound"><i class="fa fa-openid"></i> Share
from this identity</span>
- <span *ngIf="!clientNameFound"><i class="fa
fa-exclamation-circle"></i> Sharing disabled</span>
+ <button *ngIf="canAuthorize(identity)" [disabled]="!inOpenIdFlow()
|| isAttributeMissing(identity) || !isClientVerified()"
(click)="loginIdentity(identity)" class="btn btn-primary mr-1 openid-login">
+ <span *ngIf="isClientVerified()"><i class="fa fa-openid"></i>
Share from this identity</span>
+ <span *ngIf="!isClientVerified()"><i class="fa
fa-exclamation-circle"></i> Sharing disabled</span>
</button>
</div>
</div>
diff --git a/src/app/identity-list/identity-list.component.ts
b/src/app/identity-list/identity-list.component.ts
index 6aaaba5..e0c0201 100644
--- a/src/app/identity-list/identity-list.component.ts
+++ b/src/app/identity-list/identity-list.component.ts
@@ -23,14 +23,10 @@ export class IdentityListComponent implements OnInit {
requestedAttributes: any;
missingAttributes: any;
attributes: any;
- tickets: any;
- clientName: any;
identities: Identity[];
- identityNameMapper: any;
showConfirmDelete: any;
connected: any;
modalOpened: any;
- clientNameFound: any;
errorInfos: any;
searchTerm: any;
@@ -45,12 +41,10 @@ export class IdentityListComponent implements OnInit {
ngOnInit() {
this.attributes = {};
- this.tickets = {};
this.identities = [];
this.showConfirmDelete = null;
this.requestedAttributes = {};
this.missingAttributes = {};
- this.clientName = '-';
this.connected = false;
this.modalOpened = false;
if (!this.oidcService.inOpenIdFlow()) {
@@ -61,11 +55,16 @@ export class IdentityListComponent implements OnInit {
}
}
this.updateIdentities();
- this.identityNameMapper = {};
this.errorInfos = [];
console.log('processed nginit');
}
+ cancelRequest() {
+ this.oidcService.cancelAuthorization();
+ }
+
+ isClientVerified() { return this.oidcService.isClientVerified(); }
+
confirmDelete(identity) { this.showConfirmDelete = identity; }
hideConfirmDelete() { this.showConfirmDelete = null; }
@@ -151,8 +150,6 @@ export class IdentityListComponent implements OnInit {
getScopes() { return this.oidcService.getScope(); }
- getScopesPretty() { return this.getScopes().join(', '); }
-
getMissing(identity) {
const arr = [];
let i = 0;
@@ -161,7 +158,6 @@ export class IdentityListComponent implements OnInit {
}
return arr;
}
- getMissingPretty(identity) { return this.getMissing(identity).join(', '); }
canAuthorize(identity) {
return this.inOpenIdFlow();
@@ -198,9 +194,7 @@ export class IdentityListComponent implements OnInit {
this.identityService.getIdentities().subscribe(identities => {
this.identities = [];
let i;
- this.identityNameMapper = {};
for (i = 0; i < identities.length; i++) {
- this.identityNameMapper[identities[i].pubkey] = identities[i].name;
this.identities.push(identities[i]);
}
@@ -219,13 +213,6 @@ export class IdentityListComponent implements OnInit {
});
}
- getAudienceName(ticket) {
- if (undefined === this.identityNameMapper[ticket.audience]) {
- return 'Unknown';
- }
- return this.identityNameMapper[ticket.audience];
- }
-
isConnected() {
return this.connected;
}
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';
import { Identity } from './identity';
import { ConfigService } from './config.service';
import { Router } from '@angular/router';
+import { GnsService } from './gns.service';
@Injectable()
export class OpenIdService {
params: any;
inOidcFlow: Boolean;
+ clientNameVerified: Boolean;
+ clientName: String;
constructor(private http: HttpClient,
private config: ConfigService,
+ private gnsService: GnsService,
private router: Router) {
this.params = {};
this.inOidcFlow = false;
}
+
+ getClientName() {
+ this.clientNameVerified = undefined;
+ if (!this.inOpenIdFlow()) {
+ return;
+ }
+ this.gnsService.getClientName(this.getClientId())
+ .subscribe(record => {
+ const records = record.data;
+ console.log(records);
+ for (let i = 0; i < records.length; i++) {
+ if (records[i].record_type !== 'RECLAIM_OIDC_CLIENT') {
+ continue;
+ }
+ this.clientName = records[i].value;
+ this.clientNameVerified = true;
+ return;
+ }
+ this.clientNameVerified = false;
+ }, err => {
+ console.log(err);
+ this.clientNameVerified = false;
+ });
+ }
+
+ isClientVerified() { return this.clientNameVerified; }
login(identity: Identity) {
const httpOptions = {
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [reclaim-ui] 165/459: minor fixes, (continued)
- [reclaim-ui] 165/459: minor fixes, gnunet, 2021/06/11
- [reclaim-ui] 173/459: various fixed and improvements, gnunet, 2021/06/11
- [reclaim-ui] 199/459: Merge branch 'master' of gitlab.com:reclaimid/ui, gnunet, 2021/06/11
- [reclaim-ui] 172/459: manual merge from https://gitlab.com/voggenre/ui due to refactoring, gnunet, 2021/06/11
- [reclaim-ui] 169/459: display name correctly, gnunet, 2021/06/11
- [reclaim-ui] 194/459: fix attest parsing, gnunet, 2021/06/11
- [reclaim-ui] 174/459: fix build, gnunet, 2021/06/11
- [reclaim-ui] 177/459: fix getter, gnunet, 2021/06/11
- [reclaim-ui] 168/459: actually initiate verify, gnunet, 2021/06/11
- [reclaim-ui] 197/459: link to fhg account, gnunet, 2021/06/11
- [reclaim-ui] 167/459: more refactoring and cleanup,
gnunet <=
- [reclaim-ui] 175/459: fix, gnunet, 2021/06/11
- [reclaim-ui] 181/459: actually fix reference name display, gnunet, 2021/06/11
- [reclaim-ui] 200/459: webfinger, gnunet, 2021/06/11
- [reclaim-ui] 170/459: update dependencies, gnunet, 2021/06/11
- [reclaim-ui] 205/459: login via omejdn:api works, gnunet, 2021/06/11
- [reclaim-ui] 185/459: minor fixes, gnunet, 2021/06/11
- [reclaim-ui] 206/459: attestation name added, gnunet, 2021/06/11
- [reclaim-ui] 186/459: update to new API and structure, gnunet, 2021/06/11
- [reclaim-ui] 208/459: store idProvider/Attestation(not working), gnunet, 2021/06/11
- [reclaim-ui] 207/459: improved emailNotFoundAlert, gnunet, 2021/06/11