gnunet-svn
[Top][All Lists]
Advanced

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

[reclaim-ui] 371/459: attribute import done


From: gnunet
Subject: [reclaim-ui] 371/459: attribute import done
Date: Fri, 11 Jun 2021 23:27:43 +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 1f678029409df0f3b5ee16f7ff25ec8788072642
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Fri Dec 25 18:54:51 2020 +0900

    attribute import done
---
 src/app/credential.service.ts                      |  4 +--
 src/app/edit-identity/edit-identity.component.html |  3 ++
 .../import-attributes.component.ts                 | 37 ++++++++++++++++------
 src/assets/config.json                             |  2 +-
 4 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/src/app/credential.service.ts b/src/app/credential.service.ts
index edeaae0..699324f 100644
--- a/src/app/credential.service.ts
+++ b/src/app/credential.service.ts
@@ -22,8 +22,8 @@ export class CredentialService {
     getOauthConfig(idProvider: IdProvider, scopes: Scope[]){
         var redirectUri;
         if (window.location.href.includes('localhost')){
-            const user = localStorage.getItem('userForAttestation');
-            redirectUri = 'http://localhost:4200/edit-credentials/' + user;
+            const user = localStorage.getItem('userForCredential');
+            redirectUri = 'http://localhost:4200/import-attributes/' + user;
         }
         else {
             redirectUri = "https://ui.reclaim";;
diff --git a/src/app/edit-identity/edit-identity.component.html 
b/src/app/edit-identity/edit-identity.component.html
index 716bb4e..a5b8e83 100644
--- a/src/app/edit-identity/edit-identity.component.html
+++ b/src/app/edit-identity/edit-identity.component.html
@@ -363,6 +363,9 @@
         <span class="fa fa-openid"></span>
         {{ getMessage("edit_identity_html@manageCreds") }}
       </button>
+      <button *ngIf="!inOpenIdFlow() && isExperimental()" class="btn 
btn-primary" [routerLink]="['/import-attributes', identity.name ]" 
[style.float]="'right'">
+        <span class="fa fa-download"></span> 
{{getMessage("edit_identity_html@linkAccount")}}
+      </button>
     </div>
   </div>
 </div>
diff --git a/src/app/import-attributes/import-attributes.component.ts 
b/src/app/import-attributes/import-attributes.component.ts
index e036681..b6c8a00 100644
--- a/src/app/import-attributes/import-attributes.component.ts
+++ b/src/app/import-attributes/import-attributes.component.ts
@@ -61,7 +61,13 @@ export class ImportAttributesComponent implements OnInit {
       }
       this.configureOauthService();
       if (!localStorage.getItem("credentialCode")){
-        this.oauthService.loadDiscoveryDocumentAndTryLogin();
+        this.oauthService.loadDiscoveryDocumentAndTryLogin().then(success => {
+          console.log("Login successful: "+this.oauthService.getIdToken());
+          this.newCredential.name = this.newIdProvider.name + "oidcjwt";
+          this.newCredential.value = this.oauthService.getIdToken();
+          this.importAttributesFromCredential();
+        });
+
       }
       else{
         
this.oauthService.loadDiscoveryDocumentAndTryLogin(loginOptions).then(success 
=> {
@@ -114,21 +120,34 @@ export class ImportAttributesComponent implements OnInit {
         console.log("Trying to import " + cred.attributes.length + " 
attributes");
 
         for (var attr of cred.attributes) {
+          if ((attr.name == "sub") ||
+              (attr.name == "nonce") ||
+              (attr.name == "email_verified") ||
+              (attr.name == "phone_number_verified")) {
+            continue;
+          }
           //New attribute with name == claim name
-          var attestation = new Attribute(attr.name, '', cred.id, attr.id, 
'STRING', '1');
-          promises = promises.concat (this.storeAttribute(attestation));
+          var attestation = new Attribute(attr.name, '', cred.id, attr.name, 
'STRING', '1');
+          promises.push(
+            from(this.reclaimService.addAttribute(this.identity, 
attestation)));
+          //promises = promises.concat (this.storeAttribute(attestation));
         }
-        forkJoin(promises).pipe(
-          finalize(() => {
-            //FIXME cleanup
-          }))
+        forkJoin(promises)
+          .pipe(
+            finalize(() => {
+              this.newIdProvider.url = '';
+              this.newIdProvider.name = '';
+              localStorage.removeItem('newIdProviderURL');
+              localStorage.removeItem("credentialCode");
+              this.oauthService.logOut();
+            })
+          )
           .subscribe(res => {
             this.router.navigate(['/edit-identity', this.identity.name]);
           },
           err => {
             console.log(err);
-            EMPTY
-          });;
+          });
       });
     });
   }
diff --git a/src/assets/config.json b/src/assets/config.json
index 9245d6d..4c424c6 100644
--- a/src/assets/config.json
+++ b/src/assets/config.json
@@ -1,4 +1,4 @@
 {
     "apiUrl": "http://localhost:7776";,
-    "experiments": false
+    "experiments": true
 }

-- 
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]