gnunet-svn
[Top][All Lists]
Advanced

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

[reclaim-ui] 209/459: trying to save accesstoken in localStorage


From: gnunet
Subject: [reclaim-ui] 209/459: trying to save accesstoken in localStorage
Date: Fri, 11 Jun 2021 23:25: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 860454fec4af930714ebaad185ac86818ebc791d
Author: anna wimbauer <anna.wibauer@gmx.de>
AuthorDate: Mon Jun 8 23:29:55 2020 +0200

    trying to save accesstoken in localStorage
---
 src/app/edit-identity/edit-identity.component.html |  7 +++-
 src/app/edit-identity/edit-identity.component.ts   | 45 ++++++++++++++++------
 2 files changed, 38 insertions(+), 14 deletions(-)

diff --git a/src/app/edit-identity/edit-identity.component.html 
b/src/app/edit-identity/edit-identity.component.html
index 5b9a7fc..6bed8eb 100644
--- a/src/app/edit-identity/edit-identity.component.html
+++ b/src/app/edit-identity/edit-identity.component.html
@@ -162,9 +162,12 @@
     <button *ngIf="isExperimental() && !newIdProviderDiscovered()" class="btn 
btn-primary mb-4 fhg-link" (click)="getFhGAttestation()">
       <span class="fa fa-user"></span> Link Fraunhofer Account
     </button>
-
+    <!--IdProvider Exists already warning-->
+    <div *ngIf="!emailNotFoundAlertClosed && webfingerEmail==''" class="alert 
alert-danger alert-dismissible fade show my-2" role="alert">
+      <span class="fa fa-warning"></span> This Provider linked to this website 
is already linked.
+    </div>
     <!--Link account-->
-    <button *ngIf="isExperimental() && newIdProviderDiscovered()" class="btn 
btn-primary mb-4 fhg-link" (click)="loginFhgAccount()">
+    <button *ngIf="isExperimental() && newIdProviderDiscovered() && 
!discoveredIdProviderExistsAlready()" 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 bf26167..6047ba5 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: any[];
+  accessToken: any[];
   newIdProvider: string;
   emailNotFoundAlertClosed: boolean;
 
@@ -55,9 +56,9 @@ export class EditIdentityComponent implements OnInit {
     this.optionalAttested = [];
     this.attestationValues = {};
     this.webfingerEmail = '';
-    this.idProvider = this.getAllIdProvider();
     this.newIdProvider = '';
     this.emailNotFoundAlertClosed = true;
+    this.loadIdProviderAndAccessTokenFromLocalStorage();
     this.identity = new Identity('','');
     this.newAttribute = new Attribute('', '', '', '', 'STRING', '');
     this.newAttested = new Attribute('', '', '', '', 'STRING', '');
@@ -652,6 +653,13 @@ export class EditIdentityComponent implements OnInit {
     return true;
   }
 
+  discoveredIdProviderExistsAlready(){
+    if (this.idProvider.includes(this.newIdProvider)){
+      return true;
+    }
+    return false;
+  }
+
   idProviderFound(){
     if (localStorage.getItem('idProvider') == null){
       return false;
@@ -670,13 +678,6 @@ export class EditIdentityComponent implements OnInit {
     return this.newIdProvider.split('//')[1];
   }
 
-  getAllIdProvider(){
-    if (!this.idProviderFound()){
-      return [];
-    }
-    return localStorage.getItem('idProvider').split(',');
-  }
-
   loginFhgAccount(){
     var authCodeFlowConfig = 
this.oauthHelperService.getOauthConfig(this.newIdProvider);
     this.oauthService.configure(authCodeFlowConfig);
@@ -687,8 +688,11 @@ export class EditIdentityComponent implements OnInit {
     }
     this.idProvider.push(this.newIdProvider);
     this.newIdProvider = '';
-    localStorage.setItem('idProvider', localStorage.getItem('idProvider') + 
',' + this.getId().name);
-    this.addAttestation().subscribe(res => {
+    console.log (this.getAccessToken());
+    this.accessToken.push(this.getAccessToken());
+    localStorage.setItem('idProvider', localStorage.getItem('idProvider') + 
"{" + this.getId().name + ";" + this.getAccessToken() + "}");
+    
+    /* this.addAttestation().subscribe(res => {
       console.log(res);
       this.updateAttestations();
     },
@@ -696,13 +700,30 @@ export class EditIdentityComponent implements OnInit {
       console.log(err);
       //this.errorInfos.push("Failed to update identity ``" +  
this.identityInEdit.name + "''");
       EMPTY
-    });;
+    });; */
   }
 
   getId (): any{
     return this.oauthService.getIdentityClaims();
   }
 
+  getAccessToken () {
+    return this.oauthService.getAccessToken();
+  }
+
+  loadIdProviderAndAccessTokenFromLocalStorage(){
+    this.idProvider = [];
+    this.accessToken = [];
+    if (!this.idProviderFound()){
+      return;
+    }
+    const idProviderAndAccessToken = 
localStorage.getItem('idProvider').split('{');
+    idProviderAndAccessToken.forEach(element => {
+      this.idProvider.push(element.split(';')[0]);
+      this.accessToken.push((element.split(';')[1]).split('}')[0]);
+    });
+  }
+
   addAttestation() {
     const newAttestation = new Attestation (this.getId().name, 
this.getId().id, this.getId().type, 'openID', this.newIdProvider, 
this.getAttestationExpiration(), []);
     const promises = [];

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