[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[reclaim-ui] 417/459: slim down attribute import
From: |
gnunet |
Subject: |
[reclaim-ui] 417/459: slim down attribute import |
Date: |
Fri, 11 Jun 2021 23:28:29 +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 55dba06fd5039bfa584afa687f318f49200f43fd
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Wed Jan 6 01:11:25 2021 +0900
slim down attribute import
---
src/app/credential.service.ts | 2 +-
src/app/edit-identity/edit-identity.component.html | 5 +-
src/app/edit-identity/edit-identity.component.ts | 22 ++--
src/app/identity-list/identity-list.component.ts | 2 +-
.../import-attributes.component.css | 6 +-
.../import-attributes.component.ts | 143 +--------------------
src/locales/de/messages.json | 2 +
src/locales/en/messages.json | 2 +
8 files changed, 34 insertions(+), 150 deletions(-)
diff --git a/src/app/credential.service.ts b/src/app/credential.service.ts
index 2bce6ac..0f25269 100644
--- a/src/app/credential.service.ts
+++ b/src/app/credential.service.ts
@@ -25,7 +25,7 @@ export class CredentialService {
if (window.location.href.includes('localhost')){
const user = localStorage.getItem('userForCredential');
if (window.location.href.includes('import-attributes')){
- redirectUri = 'http://localhost:4200/import-attributes/' + user;
+ redirectUri = 'http://localhost:4200/edit-identity/' + user;
} else {
redirectUri = 'http://localhost:4200/edit-identity/' + user;
}
diff --git a/src/app/edit-identity/edit-identity.component.html
b/src/app/edit-identity/edit-identity.component.html
index ba4875c..e6b8306 100644
--- a/src/app/edit-identity/edit-identity.component.html
+++ b/src/app/edit-identity/edit-identity.component.html
@@ -70,13 +70,16 @@
<i *ngIf="attributesToOverwriteOnImport.length == 0" class="fa
fa-spinner fa-spin"></i>
</div>
</div>
- <div *ngIf="validImportEmail && !importInProgress" class="col-sm alert
alert-primary alert-dismissible fade show my-2" role="alert" >
+ <div *ngIf="validImportEmail && !importInProgress" class="col-sm alert
alert-primary alert-dismissible show my-2" role="alert" >
{{getMessage("edit_identity_html@importInfo", {ISSUERNAME:
getImportIssuerName()})}}<br/>
<i>{{getMessage("Note")}}</i>{{getMessage("edit_credentials_html@linkAccountInfo2")}}
<br/>
<button class="ml-1 btn btn-primary" (click)="import()">
<span class="fa fa-download"></span>
{{getMessage("edit_identity_html@importFrom", {ISSUERNAME:
getImportIssuerName()})}}
</button>
+ <button type="button" class="btn btn-primary" (click)="validImportEmail =
false">
+ <span class="fa fa-times"></span> {{ getMessage("Dismiss") }}
+ </button>
</div>
<!-- Attribute table -->
diff --git a/src/app/edit-identity/edit-identity.component.ts
b/src/app/edit-identity/edit-identity.component.ts
index 9bd44e4..a68618c 100644
--- a/src/app/edit-identity/edit-identity.component.ts
+++ b/src/app/edit-identity/edit-identity.component.ts
@@ -596,6 +596,7 @@ export class EditIdentityComponent implements OnInit {
tryImportCredential() {
if (this.importIdProvider.url === '') {
+ console.log("No ID provider flow to pick up from...")
this.importInProgress = false;
return;
}
@@ -634,6 +635,7 @@ export class EditIdentityComponent implements OnInit {
this.attributesToImport = [];
this.attributesToOverwriteOnImport = [];
localStorage.removeItem('importIdProviderURL');
+ localStorage.removeItem('emailForCredential');
localStorage.removeItem('credentialCode');
localStorage.removeItem('oidcRequestState');
localStorage.removeItem('importTargetComponent');
@@ -665,6 +667,7 @@ export class EditIdentityComponent implements OnInit {
this.attributesToImport = [];
this.attributesToOverwriteOnImport = [];
localStorage.removeItem('importIdProviderURL');
+ localStorage.removeItem('emailForCredential');
localStorage.removeItem('credentialCode');
localStorage.removeItem('oidcRequestState');
localStorage.removeItem('importTargetComponent');
@@ -766,16 +769,19 @@ export class EditIdentityComponent implements OnInit {
}
private validateEmailForImport() {
- var emailAddr = null;
+ var emailAddr = localStorage.getItem('emailForCredential');
this.importInProgress = false;
- for (let attr of this.attributes) {
- if (attr.name !== 'email') {
- continue;
+ if ((undefined === emailAddr) || (null == emailAddr)) {
+ for (let attr of this.attributes) {
+ if (attr.name !== 'email') {
+ continue;
+ }
+ console.log("Found email attribute " + attr.value);
+ emailAddr = this.isClaimCred(attr) ? this.getCredValue(attr) :
attr.value;
+ break;
}
- console.log("Found email attribute " + attr.value);
- emailAddr = attr.value;
- break;
}
+ console.log("Checking email "+ emailAddr);
if ((null == emailAddr) ||
!emailAddr.includes('@')) {
this.validImportEmail = false;
@@ -942,4 +948,4 @@ export class EditIdentityComponent implements OnInit {
}
-}
+ }
diff --git a/src/app/identity-list/identity-list.component.ts
b/src/app/identity-list/identity-list.component.ts
index 12d9ade..eb11e2a 100644
--- a/src/app/identity-list/identity-list.component.ts
+++ b/src/app/identity-list/identity-list.component.ts
@@ -70,7 +70,7 @@ export class IdentityListComponent implements OnInit {
var targetComponent = localStorage.getItem('importTargetComponent');
if ((undefined === targetComponent) ||
(null === targetComponent)) {
- this.router.navigate(['/import-attributes', user]);
+ this.router.navigate(['/edit-identity', user]);
} else {
this.router.navigate(['/edit-identity', user]);
}
diff --git a/src/app/import-attributes/import-attributes.component.css
b/src/app/import-attributes/import-attributes.component.css
index ca84834..074827e 100644
--- a/src/app/import-attributes/import-attributes.component.css
+++ b/src/app/import-attributes/import-attributes.component.css
@@ -8,16 +8,18 @@
}
.invalid.email-status-wrapper:after {
- font-family: 'FontAwesome';
+ font-family: 'Font Awesome 5 Free';
content: '\f071';
+ font-weight: 900;
position: absolute;
right: 1.25em;
top: 0.5em;
}
.valid.email-status-wrapper:after {
- font-family: 'FontAwesome';
+ font-family: 'Font Awesome 5 Free';
content: '\f00c';
+ font-weight: 900;
position: absolute;
right: 1.25em;
top: 0.5em;
diff --git a/src/app/import-attributes/import-attributes.component.ts
b/src/app/import-attributes/import-attributes.component.ts
index 6720e16..df993ff 100644
--- a/src/app/import-attributes/import-attributes.component.ts
+++ b/src/app/import-attributes/import-attributes.component.ts
@@ -57,38 +57,6 @@ export class ImportAttributesComponent implements OnInit {
this.loadScopesFromLocalStorage()
this.loadIdProviderFromLocalStorage();
this.credentials = [];
- if (this.newIdProvider.url !== ''){
- const loginOptions: LoginOptions = {
- customHashFragment: "?code="+localStorage.getItem("credentialCode") +
"&state=" + localStorage.getItem("credentialState") + "&session_state="+
localStorage.getItem("credentialSession_State"),
- }
- this.configureOauthService();
- this.inProgress = true;
- if (!localStorage.getItem("credentialCode")){
- this.oauthService.loadDiscoveryDocumentAndTryLogin().then(success => {
- if (!success || (null == this.oauthService.getIdToken())) {
- this.inProgress = false;
- return;
- }
- 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
=> {
- if (!success || (null == this.oauthService.getIdToken())) {
- this.inProgress = false;
- return;
- }
- 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 => {
if (p['id'] === undefined) {
return;
@@ -105,92 +73,8 @@ export class ImportAttributesComponent implements OnInit {
}
loadIdProviderFromLocalStorage(){
- this.newIdProvider.url = localStorage.getItem("newIdProviderURL") || '';
- this.newIdProvider.name =
this.getNewIdProviderName(this.newIdProvider.url);
- }
-
- storeAttribute(attr: Attribute) {
- this.reclaimService.addAttribute(this.identity, attr)
- }
-
- importAttributesFromCredential() {
- this.inProgress = true;
- this.reclaimService.addCredential(this.identity,
this.newCredential).subscribe(res => {
- console.log("Stored credential");
- this.reclaimService.getCredentials(this.identity).subscribe(creds => {
- this.reclaimService.getAttributes(this.identity).subscribe(attrs => {
-
- 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!");
- this.inProgress = false;
- return;
- }
- 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.name,
'STRING', '1');
- for (let existAttr of attrs) {
- /* Overwrite existing */
- if (existAttr.name !== attr.name) {
- continue;
- }
- attestation.id = existAttr.id;
- break;
- }
-
- promises.push(
- from(this.reclaimService.addAttribute(this.identity,
attestation)));
- }
- forkJoin(promises)
- .pipe(
- finalize(() => {
- this.newIdProvider.url = '';
- this.newIdProvider.name = '';
- localStorage.removeItem('newIdProviderURL');
- localStorage.removeItem('credentialCode');
- this.inProgress = false;
- this.oauthService.logOut();
- })
- )
- .subscribe(res => {
- this.router.navigate(['/edit-identity', this.identity.name]);
- },
- err => {
- console.log(err);
- });
- });
- });
- });
- }
-
- getNewIdProviderName(url: string){
- return url.split('//')[1];
- }
-
- getNewCredentialExpiration(){
- var exp = new Date(0);
- exp.setMilliseconds(this.oauthService.getIdTokenExpiration());
- return exp.toLocaleString();
- }
-
- resetNewIdProvider(){
- this.newIdProvider.url = '';
- this.newIdProvider.name = '';
- localStorage.removeItem('newIdProviderURL');
+ this.newIdProvider.url = localStorage.getItem("importIdProviderURL") || '';
+ this.newIdProvider.name = this.newIdProvider.url.split('//')[1];
}
logOutFromOauthService(){
@@ -204,20 +88,11 @@ export class ImportAttributesComponent implements OnInit {
return this.oauthService.hasValidAccessToken();
}
- cancelAdding(){
- this.logOutFromOauthService();
- this.resetNewIdProvider();
- this.resetScopes();
- this.newCredential.value = '';
- this.newCredential.name = '';
- }
-
-
//Webfinger
-
discoverIdProvider() {
this.discoveringIdProvider = true;
localStorage.setItem('userForCredential', this.identity.name);
+ localStorage.setItem('emailForCredential', this.webfingerEmail);
let account = this.webfingerEmail;
if (this.configService.get().experiments) {
if (this.webfingerEmail.substr(this.webfingerEmail.indexOf('@')+1) ===
'aisec.fraunhofer.de') {
@@ -230,8 +105,8 @@ export class ImportAttributesComponent implements OnInit {
this.credentialService.getLink(account).subscribe (idProvider => {
this.discoveringIdProvider = false;
this.newIdProvider.url = (idProvider.links [0]).href;
- localStorage.setItem('newIdProviderURL', this.newIdProvider.url);
- this.newIdProvider.name =
this.getNewIdProviderName(this.newIdProvider.url);
+ localStorage.setItem('importIdProviderURL', this.newIdProvider.url);
+ this.newIdProvider.name = this.newIdProvider.url.split('//')[1];
console.log(this.newIdProvider.url);
this.getScopes();
this.errorMessage = '';
@@ -285,12 +160,7 @@ export class ImportAttributesComponent implements OnInit {
);
}
- newIdProviderDiscovered(){
- if (this.newIdProvider.url == ''){
- return false;
- }
- return true;
- }
+
validateEmail() {
if (!this.webfingerEmail.includes('@')){
@@ -327,7 +197,6 @@ export class ImportAttributesComponent implements OnInit {
}
cancelLinking(){
- this.resetNewIdProvider();
this.resetScopes();
this.webfingerEmail = '';
}
diff --git a/src/locales/de/messages.json b/src/locales/de/messages.json
index 0f779df..8bd7978 100644
--- a/src/locales/de/messages.json
+++ b/src/locales/de/messages.json
@@ -9,6 +9,8 @@
"Delete": "Löschen",
"Edit": "Ändern",
"Add": "Hinzufügen",
+ "Name": "Name",
+ "Dismiss": "Ausblenden",
"Settings": "Einstellungen",
"Save": "Speichern",
"Note": "Hinweis: ",
diff --git a/src/locales/en/messages.json b/src/locales/en/messages.json
index e82f5b3..5e348cf 100644
--- a/src/locales/en/messages.json
+++ b/src/locales/en/messages.json
@@ -9,6 +9,8 @@
"Delete": "Delete",
"Edit": "Edit",
"Add": "Add",
+ "Name": "Name",
+ "Dismiss": "Dismiss",
"Settings": "Settings",
"Save": "Save",
"Note": "Note: ",
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [reclaim-ui] 389/459: update, (continued)
- [reclaim-ui] 389/459: update, gnunet, 2021/06/11
- [reclaim-ui] 414/459: replace table, gnunet, 2021/06/11
- [reclaim-ui] 400/459: fix, gnunet, 2021/06/11
- [reclaim-ui] 425/459: fix logo, gnunet, 2021/06/11
- [reclaim-ui] 434/459: Added translation using Weblate (Portuguese (Brazil)), gnunet, 2021/06/11
- [reclaim-ui] 429/459: yarn upgrade, gnunet, 2021/06/11
- [reclaim-ui] 390/459: update dependencies, gnunet, 2021/06/11
- [reclaim-ui] 408/459: various fixes, gnunet, 2021/06/11
- [reclaim-ui] 398/459: select attributes to overwrite, gnunet, 2021/06/11
- [reclaim-ui] 435/459: Translated using Weblate (Portuguese), gnunet, 2021/06/11
- [reclaim-ui] 417/459: slim down attribute import,
gnunet <=
- [reclaim-ui] 415/459: table header, gnunet, 2021/06/11
- [reclaim-ui] 439/459: Added translation using Weblate (Russian), gnunet, 2021/06/11
- [reclaim-ui] 448/459: Translated using Weblate (French), gnunet, 2021/06/11
- [reclaim-ui] 402/459: fix icons, translations, gnunet, 2021/06/11
- [reclaim-ui] 441/459: Translated using Weblate (Portuguese), gnunet, 2021/06/11
- [reclaim-ui] 420/459: fix, gnunet, 2021/06/11
- [reclaim-ui] 443/459: Translated using Weblate (Spanish), gnunet, 2021/06/11
- [reclaim-ui] 449/459: Translated using Weblate (French), gnunet, 2021/06/11
- [reclaim-ui] 421/459: import fix, gnunet, 2021/06/11
- [reclaim-ui] 453/459: Translated using Weblate (French), gnunet, 2021/06/11