gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[reclaim-ui] 389/459: update


From: gnunet
Subject: [reclaim-ui] 389/459: update
Date: Fri, 11 Jun 2021 23:28:01 +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 a4194a558d0bc0331039cf28b6536c72a4fe088c
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Wed Dec 30 14:36:23 2020 +0900

    update
---
 src/app/credential.service.ts                      | 12 +++++++
 .../edit-credentials.component.html                |  8 ++---
 .../edit-credentials/edit-credentials.component.ts |  3 ++
 src/app/edit-identity/edit-identity.component.html | 15 ++++++---
 src/app/edit-identity/edit-identity.component.ts   | 38 +++++++---------------
 src/app/identity-list/identity-list.component.ts   |  8 ++++-
 .../import-attributes.component.ts                 | 15 +++++++--
 src/locales/de/messages.json                       |  9 ++++-
 src/locales/en/messages.json                       |  2 --
 9 files changed, 68 insertions(+), 42 deletions(-)

diff --git a/src/app/credential.service.ts b/src/app/credential.service.ts
index 550f0d3..9c6e58e 100644
--- a/src/app/credential.service.ts
+++ b/src/app/credential.service.ts
@@ -81,4 +81,16 @@ export class CredentialService {
         return this.http.get<any>(url);
     }
 
+    mapIssuerName(iss: string): string {
+      if (iss.includes("omejdn.nslab.ch")) {
+        return "Berner Fachhochschule";
+      } else if (iss.includes("as.aisec.fraunhofer.de")) {
+        return "Fraunhofer AISEC";
+      }
+      return iss;
+    }
+
+    getIssuerName(cred: Credential) {
+      return this.mapIssuerName(cred.name);
+    }
 }
diff --git a/src/app/edit-credentials/edit-credentials.component.html 
b/src/app/edit-credentials/edit-credentials.component.html
index 241c6fa..ab4475d 100644
--- a/src/app/edit-credentials/edit-credentials.component.html
+++ b/src/app/edit-credentials/edit-credentials.component.html
@@ -15,17 +15,17 @@
     <table class="table pb-1" style="" *ngIf="credentials.length > 0">
       <thead>
         <tr>
-          <th >{{getMessage("edit_credentials_html@name")}}</th>
+          <th >{{getMessage("edit_credentials_html@issuer")}}</th>
           <th >{{getMessage("edit_credentials_html@type")}}</th>
           <th >{{getMessage("edit_credentials_html@expires")}}</th>
-          <th >{{getMessage("edit_credentials_html@issuer")}}</th>
+          <th >{{getMessage("edit_credentials_html@name")}}</th>
         </tr>
       </thead>
       <tbody>
         <tr [class.alert-danger]="newCredential.name === credential.name"
           [class.alert-warning]="!isCredentialValid(credential)" *ngFor="let 
credential of credentials">
           <td>
-            <div style="min-width: 15em">{{credential.name}}</div>
+            <div style="min-width: 15em">{{getIssuerName(credential)}}</div>
           </td>
           <td>
             <div>{{credential.type}}</div>
@@ -38,7 +38,7 @@
             </div>
 </td>-->
           <td>
-            <div style="min-width: 15em">{{credential.issuer}}</div>
+            <div style="min-width: 15em">{{credential.name}}</div>
           </td>
           <td>
             <button class="btn btn-primary" 
(click)="deleteCredential(credential)">
diff --git a/src/app/edit-credentials/edit-credentials.component.ts 
b/src/app/edit-credentials/edit-credentials.component.ts
index 1ac2acf..e316d12 100644
--- a/src/app/edit-credentials/edit-credentials.component.ts
+++ b/src/app/edit-credentials/edit-credentials.component.ts
@@ -140,5 +140,8 @@ export class EditCredentialsComponent implements OnInit {
     return this.languageService.getMessage(key, sub);
   }
 
+  getIssuerName(cred: Credential): string {
+    return this.credentialService.getIssuerName(cred);
+  }
 
 }
diff --git a/src/app/edit-identity/edit-identity.component.html 
b/src/app/edit-identity/edit-identity.component.html
index 39cc4f5..82a5aa6 100644
--- a/src/app/edit-identity/edit-identity.component.html
+++ b/src/app/edit-identity/edit-identity.component.html
@@ -158,11 +158,16 @@
         </div>
       </div>
 
-      <hr>
-
+      <hr >
       <!-- All existing attributes -->
-      <h3 class="card-subtitle mb-4"> 
{{getMessage("edit_identity_html@storedAttributes")}}</h3>
-      <div class="table pb-1">
+      <div *ngIf="attributes.length == 0"
+        class="alert alert-primary">
+        {{ getMessage('identity_list_html@noAttributes1') }}
+      </div>
+      <h3 *ngIf="attributes.length > 0"
+        class="card-subtitle mb-4"> 
{{getMessage("edit_identity_html@storedAttributes")}}</h3>
+      <div *ngIf="attributes.length > 0"
+        class="table pb-1">
           <div class="row mb-3" [class.openid]="inOpenIdFlow()"
               [class.inEdit]="claim == claimInEdit"
               [class.text-primary]="isClaimRequested(claim)"
@@ -185,7 +190,7 @@
               </div>
               <div style="flex:1;" *ngIf="claim != claimInEdit">
                 <span *ngIf="!isClaimCred(claim) && (claim != claimInEdit)">{{ 
claim.value }} <i class="text-secondary" style="float:right;"><i class="fa 
fa-certificate"></i> {{ getMessage("edit_identity_html@selfissued") 
}}</i></span>
-                <span *ngIf="isClaimCred(claim) && (claim != claimInEdit)"  
>{{ getCredValue(claim) }} <i class="text-primary" style="float:right;"><i 
class="fa fa-certificate"></i> {{ getIssuer(claim) }}</i></span>
+                <span *ngIf="isClaimCred(claim) && (claim != claimInEdit)"  
>{{ getCredValue(claim) }} <i class="text-primary" style="float:right;"><i 
class="fa fa-certificate"></i> {{ getIssuerNameForAttribute(claim) }}</i></span>
               </div>
               <div *ngIf="claim == claimInEdit" style="float:right;">
                 <select class="custom-select"
diff --git a/src/app/edit-identity/edit-identity.component.ts 
b/src/app/edit-identity/edit-identity.component.ts
index b48615a..2c52cdb 100644
--- a/src/app/edit-identity/edit-identity.component.ts
+++ b/src/app/edit-identity/edit-identity.component.ts
@@ -92,9 +92,6 @@ export class EditIdentityComponent implements OnInit {
               this.identity = ids[i];
               this.updateAttributes();
               this.updateCredentials();
-              /*if (this.importIdProvider.url !== '') {
-                this.tryImportCredential();
-              }*/
             }
           }
         });
@@ -274,11 +271,6 @@ export class EditIdentityComponent implements OnInit {
   }
 
   isInConflict(attribute: Attribute): boolean {
-    /*return this.checkConflict(this.missingProfileClaims, attribute) ||
-      this.checkConflict(this.missingEmailClaims, attribute) ||
-      this.checkConflict(this.missingPhoneClaims, attribute) ||
-      this.checkConflict(this.missingAddressClaims, attribute) ||
-      this.checkConflict(this.missingNonStandardClaims, attribute) ||*/
     return this.checkConflict(this.attributes, attribute);
   }
 
@@ -487,11 +479,14 @@ export class EditIdentityComponent implements OnInit {
     return this.credentials.length > 0
   }
 
-  //FIXME credentials need an issuer field
-  getIssuer(attribute: Attribute) {
+  getImportIssuerName(): string {
+    return this.credentialService.mapIssuerName(this.importIdProvider.name);
+  }
+
+  getIssuerNameForAttribute(attribute: Attribute): string {
     for (let i = 0; i < this.credentials.length; i++) {
       if (this.credentials[i].id == attribute.credential) {
-        return this.mapIssuer(this.credentials[i].issuer);
+        return this.getIssuerName(this.credentials[i]);
       }
     }
   }
@@ -655,7 +650,8 @@ export class EditIdentityComponent implements OnInit {
               this.importIdProvider.url = '';
               this.importIdProvider.name = '';
               localStorage.removeItem('importIdProviderURL');
-              localStorage.removeItem("credentialCode");
+              localStorage.removeItem('credentialCode');
+              localStorage.removeItem('importTargetComponent');
               this.importInProgress = false;
               this.oauthService.logOut();
               this.updateAttributes();
@@ -719,27 +715,15 @@ export class EditIdentityComponent implements OnInit {
     });
   }
 
-  mapIssuer(iss: string): string {
-    if (iss.includes("omejdn.nslab.ch")) {
-      return "Berner Fachhochschule";
-    } else if (iss.includes("as.aisec.fraunhofer.de")) {
-      return "Fraunhofer AISEC";
-    }
-    return iss;
-  }
-
-
-  getImportIssuerName() {
-    return this.mapIssuer(this.importIdProvider.name);
-  }
 
-  getIssuerName(cred: Credential) {
-    return this.mapIssuer(cred.name);
+  getIssuerName(cred: Credential): string {
+    return this.credentialService.getIssuerName(cred);
   }
 
   import(){
     this.configureOauthService();
     this.oauthService.logOut(); //Make sure we logout before login
+    localStorage.setItem('importTargetComponent', 'edit-identity');
     this.oauthService.loadDiscoveryDocumentAndLogin();
   }
 
diff --git a/src/app/identity-list/identity-list.component.ts 
b/src/app/identity-list/identity-list.component.ts
index 24a7750..b40bfe4 100644
--- a/src/app/identity-list/identity-list.component.ts
+++ b/src/app/identity-list/identity-list.component.ts
@@ -65,7 +65,13 @@ export class IdentityListComponent implements OnInit {
       localStorage.setItem('credentialState', 
this.route.snapshot.queryParams["state"]);
       localStorage.setItem('credentialSession_State', 
this.route.snapshot.queryParams["session_state"]);
       var user = localStorage.getItem('userForCredential');
-      this.router.navigate(['/edit-identity', user]);
+      var targetComponent = localStorage.getItem('importTargetComponent');
+      if ((undefined === targetComponent) ||
+          (null === targetComponent)) {
+        this.router.navigate(['/import-attributes', user]);
+      } else {
+        this.router.navigate(['/edit-identity', user]);
+      }
     }
     if (!this.oidcService.inOpenIdFlow() && undefined == 
this.route.snapshot.queryParams["authz_request"]) {
       this.oidcService.parseRouteParams(this.route.snapshot.queryParams);
diff --git a/src/app/import-attributes/import-attributes.component.ts 
b/src/app/import-attributes/import-attributes.component.ts
index c298b1c..6720e16 100644
--- a/src/app/import-attributes/import-attributes.component.ts
+++ b/src/app/import-attributes/import-attributes.component.ts
@@ -118,6 +118,8 @@ export class ImportAttributesComponent implements OnInit {
     this.reclaimService.addCredential(this.identity, 
this.newCredential).subscribe(res => {
       console.log("Stored credential");
       this.reclaimService.getCredentials(this.identity).subscribe(creds => {
+        this.reclaimService.getAttributes(this.identity).subscribe(attrs => {
+
         var promises = [];
         var cred = null;
         for (var c of creds) {
@@ -141,9 +143,17 @@ export class ImportAttributesComponent implements OnInit {
           }
           //New attribute with name == claim name
           var attestation = new Attribute(attr.name, '', cred.id, attr.name, 
'STRING', '1');
+          for (let existAttr of attrs) {
+            /* Overwrite existing */
+            if (existAttr.name !== attr.name) {
+              continue;
+            }
+            attestation.id = existAttr.id;
+            break;
+          }
+
           promises.push(
             from(this.reclaimService.addAttribute(this.identity, 
attestation)));
-          //promises = promises.concat (this.storeAttribute(attestation));
         }
         forkJoin(promises)
           .pipe(
@@ -151,7 +161,7 @@ export class ImportAttributesComponent implements OnInit {
               this.newIdProvider.url = '';
               this.newIdProvider.name = '';
               localStorage.removeItem('newIdProviderURL');
-              localStorage.removeItem("credentialCode");
+              localStorage.removeItem('credentialCode');
               this.inProgress = false;
               this.oauthService.logOut();
             })
@@ -162,6 +172,7 @@ export class ImportAttributesComponent implements OnInit {
           err => {
             console.log(err);
           });
+        });
       });
     });
   }
diff --git a/src/locales/de/messages.json b/src/locales/de/messages.json
index f6455c2..d4bd7e5 100644
--- a/src/locales/de/messages.json
+++ b/src/locales/de/messages.json
@@ -22,6 +22,7 @@
     "authorization_request_html@retry": "Nochmal versuchen",
     "authorization_request_html@cancelRequest": "Verifikation abbrechen",
     "authorization_request_html@requestCancelled": "Anfrage abgebrochen",
+    "import_attributes_html@import": "Import",
     "edit_authorizations_html@manageAuths": "Autorisierungen verwalten für",
     "edit_authorizations_html@authEntity": "Autorisierte Partei:",
     "edit_authorizations_html@sharedAttributes": "Geteilte Attribute:",
@@ -50,14 +51,20 @@
     "edit_credentials_ts@noAccount": "Kein Konto mit diese E-Email Addresse 
gefunden",
     "edit_credentials_ts@errorWrongAddress": "Ein Fehler ist aufgetreten - Der 
Grund könnte eine falsche E-Email Adresse sein.",
     "edit_identity_html@basicInfo": "Gebräuchliche Informationen",
+    "edit_identity_html@addAttributes": "Neue Attribute hinzufügen",
+    "edit_identity_html@addStandardClaim": "Gebräuchliche, standardisierte 
Attribute:",
+    "edit_identity_html@addCustomClaim": "Benutzerdefinierte Attribute:",
+    "edit_identity_html@addRequestedMissingClaim": "Angefragte, aber fehlende 
Attribute:",
     "edit_identity_html@importInfo": "Deine E-Mail-Addresse deutet darauf hin, 
dass Du Attribute eines externen Kontos bei ``{{ISSUERNAME}}´´ importieren 
kannst.",
     "edit_identity_html@linkAccount": "Attribute importieren",
-
     "edit_identity_html@standardScopes": "Die unten stehenden Attribute 
entsprechen den standard \"scopes\" von OpenID Connect:\n``profile'', 
``email'', ``phone'' and ``address''.",
     "edit_identity_html@selfissued": "Selbst ausgestellt",
     "edit_identity_html@importFrom": "Von ``{{ISSUERNAME}}´´ importieren",
     "edit_identity_html@unset": "Nicht gesetzt",
     "edit_identity_html@attribute": "Attribut",
+    "edit_identity_html@selectAttribute": "<Attributsnamen auswählen>",
+    "edit_identity_html@storedAttributes": "Gespeicherte Attribute",
+    "edit_identity_html@name": "Name",
     "edit_identity_html@plain": "Text",
     "edit_identity_html@credential": "Attestierung",
     "edit_identity_html@selectSource": "Quelle der Attestierung",
diff --git a/src/locales/en/messages.json b/src/locales/en/messages.json
index f8cceee..4e8a1fa 100644
--- a/src/locales/en/messages.json
+++ b/src/locales/en/messages.json
@@ -23,8 +23,6 @@
     "authorization_request_html@cancelRequest": "Cancel verification request",
     "authorization_request_html@requestCancelled": "Request cancelled",
     "import_attributes_html@import": "Import",
-    "import_attributes_html@importFor": "Import attributes for",
-    "import_attributes_html@confirm": "Confirm",
     "edit_authorizations_html@manageAuths": "Manage authorizations for",
     "edit_authorizations_html@authEntity": "Authorized Entity:",
     "edit_authorizations_html@sharedAttributes": "Shared attributes:",

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]