gnunet-svn
[Top][All Lists]
Advanced

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

[reclaim-ui] 208/459: store idProvider/Attestation(not working)


From: gnunet
Subject: [reclaim-ui] 208/459: store idProvider/Attestation(not working)
Date: Fri, 11 Jun 2021 23:25:00 +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 1fe7233ece103299b4d1b234845d97d4f6c72554
Author: anna wimbauer <anna.wibauer@gmx.de>
AuthorDate: Wed Jun 3 18:03:07 2020 +0200

    store idProvider/Attestation(not working)
---
 src/app/edit-identity/edit-identity.component.html |  8 +--
 src/app/edit-identity/edit-identity.component.ts   | 72 ++++++++++++++++------
 src/app/oauth-helper.service.ts                    |  6 +-
 3 files changed, 59 insertions(+), 27 deletions(-)

diff --git a/src/app/edit-identity/edit-identity.component.html 
b/src/app/edit-identity/edit-identity.component.html
index 6619623..5b9a7fc 100644
--- a/src/app/edit-identity/edit-identity.component.html
+++ b/src/app/edit-identity/edit-identity.component.html
@@ -145,7 +145,7 @@
     </div>
 
     <!--IdProvider-Discovery-->
-    <div *ngIf="!idProviderFound()" class="input-group my-2 col-lg-4">
+    <div *ngIf="!newIdProviderDiscovered()" class="input-group my-2 col-lg-4">
       <div class="input-group-prepend">
         <span class="input-group-text">@</span>
       </div>
@@ -159,13 +159,13 @@
     <div *ngIf="!emailNotFoundAlertClosed && webfingerEmail==''" class="alert 
alert-danger alert-dismissible fade show my-2" role="alert">
       <span class="fa fa-warning"></span> No account found with this email
     </div>
-    <button *ngIf="isExperimental() && !idProviderFound()" class="btn 
btn-primary mb-4 fhg-link" (click)="getFhGAttestation()">
+    <button *ngIf="isExperimental() && !newIdProviderDiscovered()" class="btn 
btn-primary mb-4 fhg-link" (click)="getFhGAttestation()">
       <span class="fa fa-user"></span> Link Fraunhofer Account
     </button>
 
     <!--Link account-->
-    <button *ngIf="isExperimental() && idProviderFound()" class="btn 
btn-primary mb-4 fhg-link" (click)="loginFhgAccount()">
-      <span class="fa fa-user"></span> Link {{getIdProviderName()}} Account
+    <button *ngIf="isExperimental() && newIdProviderDiscovered()" class="btn 
btn-primary mb-4 fhg-link" (click)="loginFhgAccount()">
+      <span class="fa fa-user"></span> Link {{getNewIdProviderName()}} Account
     </button>
 
     
diff --git a/src/app/edit-identity/edit-identity.component.ts 
b/src/app/edit-identity/edit-identity.component.ts
index 00603bc..bf26167 100644
--- a/src/app/edit-identity/edit-identity.component.ts
+++ b/src/app/edit-identity/edit-identity.component.ts
@@ -34,7 +34,8 @@ export class EditIdentityComponent implements OnInit {
   requestedAttested: Attribute[];
   optionalAttested: Attribute[];
   webfingerEmail: string;
-  idProvider: string;
+  idProvider: string[];
+  newIdProvider: string;
   emailNotFoundAlertClosed: boolean;
 
   constructor(private reclaimService: ReclaimService,
@@ -54,7 +55,8 @@ export class EditIdentityComponent implements OnInit {
     this.optionalAttested = [];
     this.attestationValues = {};
     this.webfingerEmail = '';
-    this.idProvider = localStorage.getItem('idProvider');
+    this.idProvider = this.getAllIdProvider();
+    this.newIdProvider = '';
     this.emailNotFoundAlertClosed = true;
     this.identity = new Identity('','');
     this.newAttribute = new Attribute('', '', '', '', 'STRING', '');
@@ -629,9 +631,8 @@ export class EditIdentityComponent implements OnInit {
     localStorage.setItem('userForAttestation', this.identity.name);
     this.isValidEmailforDiscovery();
     this.webfingerService.getLink(this.webfingerEmail).subscribe (idProvider 
=> {
-      this.idProvider = (idProvider.links [0]).href;
-      localStorage.setItem('idProvider', this.idProvider);
-      console.log(this.idProvider);
+      this.newIdProvider = (idProvider.links [0]).href; 
+      console.log(this.newIdProvider);
       this.webfingerEmail == '';
     },
     error => {
@@ -652,39 +653,70 @@ export class EditIdentityComponent implements OnInit {
   }
 
   idProviderFound(){
-    if (this.idProvider == null){
+    if (localStorage.getItem('idProvider') == null){
       return false;
     }
     return true;
   }
 
-  getIdProviderName(){
-    return this.idProvider.split('//')[1];
+  newIdProviderDiscovered(){
+    if (this.newIdProvider == ''){
+      return false;
+    }
+    return true;
+  }
+
+  getNewIdProviderName(){
+    return this.newIdProvider.split('//')[1];
+  }
+
+  getAllIdProvider(){
+    if (!this.idProviderFound()){
+      return [];
+    }
+    return localStorage.getItem('idProvider').split(',');
   }
 
   loginFhgAccount(){
-    var authCodeFlowConfig = 
this.oauthHelperService.getOauthConfig(this.identity.name);
+    var authCodeFlowConfig = 
this.oauthHelperService.getOauthConfig(this.newIdProvider);
     this.oauthService.configure(authCodeFlowConfig);
     this.oauthService.loadDiscoveryDocumentAndLogin();
     if (this.getId() == null){
-      console.log("error: can't get id")
+      console.log("error: can't get id");
+      return;
     }
-    localStorage.setItem('idProvider', this.getId());
-    //this.addAttestation();
+    this.idProvider.push(this.newIdProvider);
+    this.newIdProvider = '';
+    localStorage.setItem('idProvider', localStorage.getItem('idProvider') + 
',' + this.getId().name);
+    this.addAttestation().subscribe(res => {
+      console.log(res);
+      this.updateAttestations();
+    },
+    err => {
+      console.log(err);
+      //this.errorInfos.push("Failed to update identity ``" +  
this.identityInEdit.name + "''");
+      EMPTY
+    });;
   }
 
   getId (): any{
     return this.oauthService.getIdentityClaims();
   }
 
-  addAttestation(){
-    const newAttestation = new Attestation (this.getId().name, 
this.getId().id, this.getId().type, 'openID', this.idProvider, 
this.getAttestationExpiration(), []);
-    this.reclaimService.addAttestation(this.identity, 
newAttestation).subscribe(res => {
-      console.log(res);
-    },
-    err => {
-      console.log(err);
-    });
+  addAttestation() {
+    const newAttestation = new Attestation (this.getId().name, 
this.getId().id, this.getId().type, 'openID', this.newIdProvider, 
this.getAttestationExpiration(), []);
+    const promises = [];
+    let i;
+    if (undefined !== this.attestations) {
+      for (i = 0; i < this.attestations.length; i++) {
+        promises.push(
+          from(this.reclaimService.addAttestation(this.identity, 
this.attestations[i])));
+      }
+    }
+    if ((newAttestation.value !== '') || (newAttestation.type !== '')) {
+      promises.push(from(this.reclaimService.addAttestation(this.identity, 
newAttestation)));
+    }
+    return forkJoin(promises);
   }
 
   getAttestationExpiration(){
diff --git a/src/app/oauth-helper.service.ts b/src/app/oauth-helper.service.ts
index 4c31644..0ffadb0 100644
--- a/src/app/oauth-helper.service.ts
+++ b/src/app/oauth-helper.service.ts
@@ -6,13 +6,13 @@ export class OauthHelperService {
 
   constructor() { }
 
-  getOauthConfig(identityName: string){
+  getOauthConfig(idProvider: string){
     const authCodeFlowConfig: AuthConfig = {
       // Url of the Identity Provider
-      issuer: localStorage.getItem('idProvider'),
+      issuer: idProvider,
   
       // URL of the SPA to redirect the user to after login
-      redirectUri: window.location.origin + '/edit-attestations/' + 
identityName,
+      redirectUri: window.location.href,
   
       // The SPA's id. The SPA is registerd with this id at the auth-server
       // clientId: 'server.code',

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