gnunet-svn
[Top][All Lists]
Advanced

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

[reclaim-ui] 234/459: adding attestation works


From: gnunet
Subject: [reclaim-ui] 234/459: adding attestation works
Date: Fri, 11 Jun 2021 23:25:26 +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 456fac4d55f8b612ae9466c17efa5ebbfe63877e
Author: anna wimbauer <anna.wibauer@gmx.de>
AuthorDate: Mon Jul 13 11:24:43 2020 +0200

    adding attestation works
---
 src/app/app.module.ts                               |  4 +++-
 .../edit-attestations.component.html                |  2 +-
 .../edit-attestations.component.ts                  | 18 +++++++-----------
 src/app/edit-identity/edit-identity.component.html  |  2 +-
 src/app/edit-identity/edit-identity.component.ts    | 21 ---------------------
 src/app/identity-list/identity-list.component.ts    |  4 +++-
 6 files changed, 15 insertions(+), 36 deletions(-)

diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 8d780ae..64708b7 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -22,6 +22,7 @@ import { EditIdentityComponent } from 
'./edit-identity/edit-identity.component';
 import { AuthorizationRequestComponent } from 
'./authorization-request/authorization-request.component';
 import { EditAuthorizationsComponent } from 
'./edit-authorizations/edit-authorizations.component';
 import { EditAttestationsComponent } from 
'./edit-attestations/edit-attestations.component';
+import { OAuthStorage } from 'angular-oauth2-oidc';
 
 @NgModule({
   declarations: [
@@ -56,7 +57,8 @@ import { EditAttestationsComponent } from 
'./edit-attestations/edit-attestations
       provide: APP_INITIALIZER,
       useFactory: (config: ConfigService) => () => config.load(),
       deps: [ConfigService], multi: true
-    }
+    },
+    { provide: OAuthStorage, useValue: localStorage },
   ],
   bootstrap: [AppComponent]
 })
diff --git a/src/app/edit-attestations/edit-attestations.component.html 
b/src/app/edit-attestations/edit-attestations.component.html
index ee7a214..879f9e5 100644
--- a/src/app/edit-attestations/edit-attestations.component.html
+++ b/src/app/edit-attestations/edit-attestations.component.html
@@ -51,7 +51,7 @@
           </td>
           <td><div style="min-width: 15em">{{newIdProvider.url}}</div></td>
           <td>
-            <button class="btn btn-primary"  (click)="saveIdProvider()">
+            <button class="btn btn-primary" 
[disabled]="!canAddAttestation(newAttestation)" (click)="saveIdProvider()">
               <span class="fa fa-plus"></span> 
             </button>
             <button class="btn btn-primary ml-2"  (click)="cancelAdding()">
diff --git a/src/app/edit-attestations/edit-attestations.component.ts 
b/src/app/edit-attestations/edit-attestations.component.ts
index 6b7f9c1..e34d4dc 100644
--- a/src/app/edit-attestations/edit-attestations.component.ts
+++ b/src/app/edit-attestations/edit-attestations.component.ts
@@ -10,6 +10,7 @@ import { AttestationService } from '../attestation.service';
 import { OAuthService } from 'angular-oauth2-oidc';
 import { IdProvider } from '../idProvider';
 import { ConstantPool } from '@angular/compiler';
+import { LoginOptions } from 'angular-oauth2-oidc';
 
 @Component({
   selector: 'app-edit-attestations',
@@ -37,13 +38,12 @@ export class EditAttestationsComponent implements OnInit {
     this.loadIdProviderFromLocalStorage();
     this.attestations = [];
     if (this.newIdProvider.url !== ''){
+      const loginOptions: LoginOptions = {
+        customHashFragment: "?code="+localStorage.getItem("attestationCode") + 
"&state=" + localStorage.getItem("attestationState") + "&session_state="+ 
localStorage.getItem("attestationSession_State"),
+      }
+      console.log(loginOptions.customHashFragment);
       
this.oauthService.configure(this.attestationService.getOauthConfig(this.newIdProvider));
-      this.oauthService.loadDiscoveryDocumentAndTryLogin().then(res => {
-        console.log("ngOnInit: logged in");
-        console.log(res);
-        console.log("Has valid accessToken: " + 
this.oauthService.hasValidAccessToken());
-        console.log("AccessToken: " + this.oauthService.getAccessToken());
-      }).catch(err => console.log(err));
+      this.oauthService.loadDiscoveryDocumentAndTryLogin(loginOptions);
     }
     this.activatedRoute.params.subscribe(p => {
       if (p['id'] === undefined) {
@@ -79,10 +79,7 @@ export class EditAttestationsComponent implements OnInit {
   addAttestation() {
     if (!this.oauthService.hasValidAccessToken()){
       console.log("No AccessToken");
-      
this.oauthService.configure(this.attestationService.getOauthConfig(this.newIdProvider));
-      this.oauthService.loadDiscoveryDocumentAndTryLogin().then(res => {
-        console.log("AddAttestation: logged in");
-        console.log(this.oauthService.getAccessToken());}).catch(err => 
console.log(err));
+      return;
     }
     this.newAttestation.value = this.oauthService.getAccessToken();
     this.reclaimService.addAttestation(this.identity, 
this.newAttestation).subscribe(res => {
@@ -154,7 +151,6 @@ export class EditAttestationsComponent implements OnInit {
 
   canAddAttestation(attestation: Attestation) {
     if(!this.oauthService.hasValidAccessToken()){
-      console.log("not logged in");
       return false;
     }
     if ((attestation.name === '')) {
diff --git a/src/app/edit-identity/edit-identity.component.html 
b/src/app/edit-identity/edit-identity.component.html
index 323cdf5..c70b141 100644
--- a/src/app/edit-identity/edit-identity.component.html
+++ b/src/app/edit-identity/edit-identity.component.html
@@ -167,7 +167,7 @@
     <button *ngIf="newIdProviderDiscovered() && !grantedAccessToIdProvider()" 
class="btn btn-primary mb-4 fhg-link" (click)="loginFhgAccount()">
       <span class="fa fa-user"></span> Grant Access to {{newIdProvider.name}}
     </button>
-    <button *ngIf="newIdProviderDiscovered()" class="btn btn-primary mb-4 
fhg-link" (click)="cancleLinking()">
+    <button *ngIf="newIdProviderDiscovered()" class="btn btn-primary mb-4 
fhg-link" (click)="cancelLinking()">
       Cancel Linking
     </button>
     </div>
diff --git a/src/app/edit-identity/edit-identity.component.ts 
b/src/app/edit-identity/edit-identity.component.ts
index f799626..816158e 100644
--- a/src/app/edit-identity/edit-identity.component.ts
+++ b/src/app/edit-identity/edit-identity.component.ts
@@ -666,17 +666,6 @@ export class EditIdentityComponent implements OnInit {
     return true;
   }
 
-
-  //not sure if needed -> should be able to link two different accounts from 
same provider
-  discoveredIdProviderExistsAlready(){
-    this.authorizations.forEach(token => {
-      if (token.idProvider == this.newIdProvider.url){
-        return true;
-      }
-    });
-    return false;
-  }
-
   newIdProviderDiscovered(){
     if (this.newIdProvider.url == ''){
       return false;
@@ -695,16 +684,6 @@ export class EditIdentityComponent implements OnInit {
     this.getId();
   }
 
-  attestationNameDuplicate(){
-    let i;
-    for (i = 0; i < this.attestations.length; i++) {
-      if (this.newAttestation.name === this.attestations[i].name) {
-        return true;
-      }
-    }
-    return false;
-  }
-
   getId (): any{
     return this.oauthService.getIdentityClaims();
   }
diff --git a/src/app/identity-list/identity-list.component.ts 
b/src/app/identity-list/identity-list.component.ts
index b5b233e..9951256 100644
--- a/src/app/identity-list/identity-list.component.ts
+++ b/src/app/identity-list/identity-list.component.ts
@@ -41,7 +41,7 @@ export class IdentityListComponent implements OnInit {
     private namestoreService: NamestoreService,
     private gnsService: GnsService,
     private modalService: ModalService,
-    private router: Router) {
+    private router: Router,) {
   }
 
   ngOnInit() {
@@ -58,6 +58,8 @@ export class IdentityListComponent implements OnInit {
     this.modalOpened = false;
     if (undefined !== this.route.snapshot.queryParams["code"]) {
       localStorage.setItem('attestationCode', 
this.route.snapshot.queryParams["code"]);
+      localStorage.setItem('attestationState', 
this.route.snapshot.queryParams["state"]);
+      localStorage.setItem('attestationSession_State', 
this.route.snapshot.queryParams["session_state"]);
       var user = localStorage.getItem('userForAttestation');
       this.router.navigate(['/edit-attestations', user]);
     }

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