[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[reclaim-ui] 369/459: add code for straight attribute import
From: |
gnunet |
Subject: |
[reclaim-ui] 369/459: add code for straight attribute import |
Date: |
Fri, 11 Jun 2021 23:27:41 +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 516c924544e633782352a6da8fe7b8cf406e358f
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Thu Dec 24 14:05:11 2020 +0900
add code for straight attribute import
---
.../import-attributes.component.ts | 54 +++++++++++++++++++++-
1 file changed, 52 insertions(+), 2 deletions(-)
diff --git a/src/app/import-attributes/import-attributes.component.ts
b/src/app/import-attributes/import-attributes.component.ts
index 3194490..e036681 100644
--- a/src/app/import-attributes/import-attributes.component.ts
+++ b/src/app/import-attributes/import-attributes.component.ts
@@ -3,6 +3,7 @@ import { ActivatedRoute, Router } from '@angular/router';
import { ReclaimService } from '../reclaim.service';
import { Identity } from '../identity';
import { Credential } from '../credential';
+import { Attribute } from '../attribute';
import { IdentityService } from '../identity.service';
import { CredentialService } from '../credential.service';
import { OAuthService } from 'angular-oauth2-oidc';
@@ -11,6 +12,9 @@ import { LoginOptions } from 'angular-oauth2-oidc';
import { Scope } from '../scope';
import { LanguageService } from '../language.service';
import { ConfigService } from '../config.service';
+import { finalize } from 'rxjs/operators';
+import { from, forkJoin, EMPTY } from 'rxjs';
+
@Component({
selector: 'app-import-attributes',
@@ -60,7 +64,12 @@ export class ImportAttributesComponent implements OnInit {
this.oauthService.loadDiscoveryDocumentAndTryLogin();
}
else{
- this.oauthService.loadDiscoveryDocumentAndTryLogin(loginOptions);
+
this.oauthService.loadDiscoveryDocumentAndTryLogin(loginOptions).then(success
=> {
+ console.log("Login successful: "+this.oauthService.getIdToken());
+ this.newCredential.name = this.newIdProvider.name + "OidcJwt";
+ this.newCredential.value = this.oauthService.getIdToken();
+ this.importAttributesFromCredential();
+ });
}
}
this.activatedRoute.params.subscribe(p => {
@@ -83,6 +92,47 @@ export class ImportAttributesComponent implements OnInit {
this.newIdProvider.name =
this.getNewIdProviderName(this.newIdProvider.url);
}
+ storeAttribute(attr: Attribute) {
+ this.reclaimService.addAttribute(this.identity, attr)
+ }
+
+ importAttributesFromCredential() {
+ this.reclaimService.addCredential(this.identity,
this.newCredential).subscribe(res => {
+ console.log("Stored credential");
+ this.reclaimService.getCredentials(this.identity).subscribe(creds => {
+ var promises = [];
+ var cred = null;
+ for (var c of creds) {
+ if (c.name == this.newCredential.name) {
+ cred = c;
+ }
+ }
+ if (null == cred) {
+ console.log("ERROR: credential was not added!");
+ return;
+ }
+ console.log("Trying to import " + cred.attributes.length + "
attributes");
+
+ for (var attr of cred.attributes) {
+ //New attribute with name == claim name
+ var attestation = new Attribute(attr.name, '', cred.id, attr.id,
'STRING', '1');
+ promises = promises.concat (this.storeAttribute(attestation));
+ }
+ forkJoin(promises).pipe(
+ finalize(() => {
+ //FIXME cleanup
+ }))
+ .subscribe(res => {
+ this.router.navigate(['/edit-identity', this.identity.name]);
+ },
+ err => {
+ console.log(err);
+ EMPTY
+ });;
+ });
+ });
+ }
+
getNewIdProviderName(url: string){
return url.split('//')[1];
}
@@ -135,7 +185,7 @@ export class ImportAttributesComponent implements OnInit {
this.credentialService.getLink(account).subscribe (idProvider => {
this.discoveringIdProvider = false;
- this.newIdProvider.url = (idProvider.links [0]).href;
+ this.newIdProvider.url = (idProvider.links [0]).href;
localStorage.setItem('newIdProviderURL', this.newIdProvider.url);
this.newIdProvider.name =
this.getNewIdProviderName(this.newIdProvider.url);
console.log(this.newIdProvider.url);
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [reclaim-ui] 370/459: build fix, (continued)
- [reclaim-ui] 370/459: build fix, gnunet, 2021/06/11
- [reclaim-ui] 364/459: fine tuning authorization, gnunet, 2021/06/11
- [reclaim-ui] 401/459: improve import logic and UI, gnunet, 2021/06/11
- [reclaim-ui] 320/459: works on chrome, gnunet, 2021/06/11
- [reclaim-ui] 342/459: Translated using Weblate (German), gnunet, 2021/06/11
- [reclaim-ui] 349/459: fix translations, gnunet, 2021/06/11
- [reclaim-ui] 387/459: update, gnunet, 2021/06/11
- [reclaim-ui] 358/459: clean up, gnunet, 2021/06/11
- [reclaim-ui] 386/459: fix import for browser plugin, other import may be broken, gnunet, 2021/06/11
- [reclaim-ui] 394/459: fix default selection, gnunet, 2021/06/11
- [reclaim-ui] 369/459: add code for straight attribute import,
gnunet <=
- [reclaim-ui] 407/459: use share icon, gnunet, 2021/06/11
- [reclaim-ui] 397/459: fix address handling, gnunet, 2021/06/11
- [reclaim-ui] 406/459: allow authorization from edit component, gnunet, 2021/06/11
- [reclaim-ui] 376/459: updatte attribute info, gnunet, 2021/06/11
- [reclaim-ui] 371/459: attribute import done, gnunet, 2021/06/11
- [reclaim-ui] 404/459: fix, gnunet, 2021/06/11
- [reclaim-ui] 368/459: settings page, experiments tweaks, gnunet, 2021/06/11
- [reclaim-ui] 395/459: fix, gnunet, 2021/06/11
- [reclaim-ui] 382/459: style adjustments, gnunet, 2021/06/11
- [reclaim-ui] 373/459: fix credential string lowercase, gnunet, 2021/06/11