[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[reclaim-ui] 237/459: moved IdProvider-Linking to edit-attestations
From: |
gnunet |
Subject: |
[reclaim-ui] 237/459: moved IdProvider-Linking to edit-attestations |
Date: |
Fri, 11 Jun 2021 23:25: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 f9fb8fcaf3fcb40d1e8e35d8a59fc74f6265fc6c
Author: anna wimbauer <anna.wibauer@gmx.de>
AuthorDate: Mon Jul 13 12:59:12 2020 +0200
moved IdProvider-Linking to edit-attestations
---
.../edit-attestations.component.html | 74 +++++++++++++++----
.../edit-attestations.component.ts | 85 +++++++++++++++++++---
src/app/edit-identity/edit-identity.component.html | 28 -------
src/app/edit-identity/edit-identity.component.ts | 75 +------------------
4 files changed, 135 insertions(+), 127 deletions(-)
diff --git a/src/app/edit-attestations/edit-attestations.component.html
b/src/app/edit-attestations/edit-attestations.component.html
index 879f9e5..a551062 100644
--- a/src/app/edit-attestations/edit-attestations.component.html
+++ b/src/app/edit-attestations/edit-attestations.component.html
@@ -19,50 +19,93 @@
</tr>
</thead>
<tbody>
- <tr [class.alert-danger]="newAttestation.name === attestation.name"
[class.alert-warning]="!isAttestationValid(attestation)" *ngFor="let
attestation of attestations">
- <td><div style="min-width: 15em">{{attestation.name}}</div></td>
+ <tr [class.alert-danger]="newAttestation.name === attestation.name"
+ [class.alert-warning]="!isAttestationValid(attestation)" *ngFor="let
attestation of attestations">
+ <td>
+ <div style="min-width: 15em">{{attestation.name}}</div>
+ </td>
<td>
<div>{{attestation.type}}</div>
</td>
<td>
<div>{{getExpiration(attestation)}}</div>
</td>
-<!--ISSUER <td>
+ <!--ISSUER <td>
<div style="min-width: 15em">
</div>
</td>-->
- <td><div style="min-width: 15em">{{attestation.issuer}}</div></td>
<td>
- <button class="btn btn-primary"
(click)="deleteAttestation(attestation)">
+ <div style="min-width: 15em">{{attestation.issuer}}</div>
+ </td>
+ <td>
+ <button class="btn btn-primary"
(click)="deleteAttestation(attestation)">
<span class="fa fa-trash"></span>
</button>
</td>
<td>
- <div *ngIf= "!isAttestationValid(attestation)"> <span
style="color:#f00"> Expired </span> <span class="fa fa-times"></span> </div>
+ <div *ngIf="!isAttestationValid(attestation)"> <span
style="color:#f00"> Expired </span> <span
+ class="fa fa-times"></span> </div>
</td>
</tr>
- <tr [class.alert-danger]="isAttestInConflict(newAttestation)"
*ngIf="newAccessGranted()">
+ <tr [class.alert-danger]="isAttestInConflict(newAttestation)"
*ngIf="loggedIn()">
+ <td>
+ <input [class.text-danger]="!attestationNameValid(newAttestation)"
placeholder="Attestation"
+ [(ngModel)]="newAttestation.name">
+ </td>
<td>
- <input [class.text-danger]="!attestationNameValid(newAttestation)"
placeholder="Attestation" [(ngModel)]="newAttestation.name">
+ <div style="min-width: 15em">JWT</div>
</td>
- <td><div style="min-width: 15em">JWT</div></td>
<td>
{{getNewAttestationExpiration()}}
</td>
- <td><div style="min-width: 15em">{{newIdProvider.url}}</div></td>
+ <td>
+ <div style="min-width: 15em">{{newIdProvider.url}}</div>
+ </td>
<td>
<button class="btn btn-primary"
[disabled]="!canAddAttestation(newAttestation)" (click)="saveIdProvider()">
- <span class="fa fa-plus"></span>
+ <span class="fa fa-plus"></span>
</button>
- <button class="btn btn-primary ml-2" (click)="cancelAdding()">
+ <button class="btn btn-primary ml-2" (click)="cancelAdding()">
<span class="fa fa-trash"></span>
</button>
</td>
</tr>
</tbody>
</table>
+
+ <!--IdProvider-Discovery-->
+ <div *ngIf="isExperimental()">
+ <div *ngIf="!newIdProviderDiscovered()" class="input-group my-2
col-lg-4">
+ <div class="input-group-prepend">
+ <span class="input-group-text">Email: </span>
+ </div>
+ <input placeholder="E-Mail Adress" class="form-control"
[(ngModel)]="webfingerEmail">
+ </div>
+ <!--Issuer Discovery Warning-->
+ <div *ngIf="!isValidEmailforDiscovery()" class="alert alert-primary
alert-dismissible fade show" role="alert">
+ <span class="fa fa-warning"></span> This is not a valid e-mail adress
+ </div>
+ <!--Email not found Warning-->
+ <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="!newIdProviderDiscovered()" class="btn btn-primary mb-4
fhg-link" (click)="discoverIdProvider()">
+ <span class="fa fa-openid"></span> Link account
+ </button>
+ <!--Link account-->
+ <button *ngIf="newIdProviderDiscovered() && !loggedIn()" 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() && !loggedIn()" class="btn
btn-primary mb-4 fhg-link" (click)="cancelLinking()">
+ Cancel Linking
+ </button>
+ </div>
<!-- Attestation creation warning -->
- <div *ngIf="newAccessGranted() && !attestationNameValid(newAttestation) ||
!attestationTypeValid(newAttestation) ||
!attestationValueValid(newAttestation)" class="alert alert-primary
alert-dismissible fade show" role="alert">
+ <div
+ *ngIf="loggedIn() && !attestationNameValid(newAttestation) ||
!attestationTypeValid(newAttestation) || !attestationValueValid(newAttestation)"
+ class="alert alert-primary alert-dismissible fade show" role="alert">
<span class="fa fa-warning"></span> Note:
<ul>
<li>Only use alphanumeric attestation names.</li>
@@ -70,7 +113,7 @@
<li>Types and values may not be empty!</li>
</ul>
</div>
- <hr/>
+ <hr />
<!-- Edit card buttons -->
<div>
<button class="btn btn-primary" (click)="goBack()"
[disabled]="!canGoBack()">
@@ -78,5 +121,4 @@
</button>
</div>
</div>
-</div>
-
+</div>
\ No newline at end of file
diff --git a/src/app/edit-attestations/edit-attestations.component.ts
b/src/app/edit-attestations/edit-attestations.component.ts
index 5d7ebeb..fd3f9de 100644
--- a/src/app/edit-attestations/edit-attestations.component.ts
+++ b/src/app/edit-attestations/edit-attestations.component.ts
@@ -9,7 +9,6 @@ import { finalize } from 'rxjs/operators';
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({
@@ -23,6 +22,8 @@ export class EditAttestationsComponent implements OnInit {
attestations: Attestation[];
newAttestation: Attestation;
newIdProvider: IdProvider;
+ webfingerEmail: string;
+ emailNotFoundAlertClosed: boolean;
constructor(private reclaimService: ReclaimService,
private identityService: IdentityService,
@@ -35,6 +36,8 @@ export class EditAttestationsComponent implements OnInit {
this.newAttestation = new Attestation('', '', '', 'JWT', '', 0, []);
this.identity = new Identity('','');
this.newIdProvider = new IdProvider ('', '', '');
+ this.webfingerEmail = '';
+ this.emailNotFoundAlertClosed = true;
this.loadIdProviderFromLocalStorage();
this.attestations = [];
if (this.newIdProvider.url !== ''){
@@ -43,7 +46,13 @@ export class EditAttestationsComponent implements OnInit {
}
console.log(loginOptions.customHashFragment);
this.oauthService.configure(this.attestationService.getOauthConfig(this.newIdProvider));
- this.oauthService.loadDiscoveryDocumentAndTryLogin(loginOptions);
+ if (!localStorage.getItem("attestationCode")){
+ this.oauthService.loadDiscoveryDocumentAndTryLogin();
+ }
+ else{
+ this.oauthService.loadDiscoveryDocumentAndTryLogin(loginOptions);
+ }
+
}
this.activatedRoute.params.subscribe(p => {
if (p['id'] === undefined) {
@@ -208,13 +217,6 @@ export class EditAttestationsComponent implements OnInit {
return url.split('//')[1];
}
- newAccessGranted(){
- if (this.newIdProvider.url !== ''){
- return true;
- }
- return false;
- }
-
getNewAttestationExpiration(){
var exp = new Date();
exp.setMilliseconds(this.oauthService.getIdTokenExpiration() / 1000);
@@ -236,6 +238,10 @@ export class EditAttestationsComponent implements OnInit {
this.oauthService.logOut(false);
}
+ loggedIn(){
+ return this.oauthService.hasValidAccessToken();
+ }
+
cancelAdding(){
this.logOutFromOauthService();
this.resetNewIdProvider();
@@ -244,4 +250,65 @@ export class EditAttestationsComponent implements OnInit {
}
+ //Webfinger
+
+ discoverIdProvider() {
+ if (this.webfingerEmail == ''){
+ return;
+ }
+ localStorage.setItem('userForAttestation', this.identity.name);
+ this.isValidEmailforDiscovery();
+ this.attestationService.getLink(this.webfingerEmail).subscribe (idProvider
=> {
+ this.newIdProvider.url = (idProvider.links [0]).href;
+ localStorage.setItem('newIdProviderURL', this.newIdProvider.url);
+ this.newIdProvider.name =
this.getNewIdProviderName(this.newIdProvider.url);
+ (idProvider.links.length > 1)? this.newIdProvider.logoutURL =
(idProvider.links [1]).href : this.newIdProvider.logoutURL =
this.newIdProvider.url;
+ localStorage.setItem('newIdProviderLogoutURL',
this.newIdProvider.logoutURL);
+ console.log(this.newIdProvider.url);
+ this.webfingerEmail == '';
+ },
+ error => {
+ if (error.status == 404){
+ this.emailNotFoundAlertClosed = false;
+ setTimeout(() => this.emailNotFoundAlertClosed = true, 20000);
+ }
+ this.webfingerEmail = '';
+ console.log (error);
+ });
+ }
+
+ newIdProviderDiscovered(){
+ if (this.newIdProvider.url == ''){
+ return false;
+ }
+ return true;
+ }
+
+ isValidEmailforDiscovery(){
+ if (!this.webfingerEmail.includes('@') && this.webfingerEmail != ''){
+ return false;
+ }
+ return true;
+ }
+
+ loginFhgAccount(){
+ var authCodeFlowConfig =
this.attestationService.getOauthConfig(this.newIdProvider);
+ this.oauthService.configure(authCodeFlowConfig);
+ this.oauthService.loadDiscoveryDocumentAndLogin();
+ }
+
+ cancelLinking(){
+ this.resetNewIdProvider();
+ this.webfingerEmail = '';
+ }
+
+ isExperimental() {
+ var exp = localStorage.getItem('reclaimExperiments');
+ return ((undefined !== exp) && ("" !== exp));
+ }
+
+
+
+
+
}
diff --git a/src/app/edit-identity/edit-identity.component.html
b/src/app/edit-identity/edit-identity.component.html
index 418ddfb..050ce37 100644
--- a/src/app/edit-identity/edit-identity.component.html
+++ b/src/app/edit-identity/edit-identity.component.html
@@ -144,34 +144,6 @@
</ul>
</div>
- <!--IdProvider-Discovery-->
- <div *ngIf="isExperimental()">
- <div *ngIf="!newIdProviderDiscovered()" class="input-group my-2 col-lg-4">
- <div class="input-group-prepend">
- <span class="input-group-text">Email: </span>
- </div>
- <input placeholder="E-Mail Adress" class="form-control"
[(ngModel)]="webfingerEmail">
- </div>
- <!--Issuer Discovery Warning-->
- <div *ngIf="!isValidEmailforDiscovery()" class="alert alert-primary
alert-dismissible fade show" role="alert">
- <span class="fa fa-warning"></span> This is not a valid e-mail adress
- </div>
- <!--Email not found Warning-->
- <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="!newIdProviderDiscovered()" class="btn btn-primary mb-4
fhg-link" (click)="discoverIdProvider()">
- <span class="fa fa-openid"></span> Link account
- </button>
- <!--Link account-->
- <button *ngIf="newIdProviderDiscovered()" 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)="cancelLinking()">
- Cancel Linking
- </button>
- </div>
-
<hr/>
<!-- Edit card buttons -->
diff --git a/src/app/edit-identity/edit-identity.component.ts
b/src/app/edit-identity/edit-identity.component.ts
index e569c61..b76395d 100644
--- a/src/app/edit-identity/edit-identity.component.ts
+++ b/src/app/edit-identity/edit-identity.component.ts
@@ -10,10 +10,8 @@ import { Attestation } from '../attestation';
import { IdentityService } from '../identity.service';
import { finalize } from 'rxjs/operators';
import { from, forkJoin, EMPTY } from 'rxjs';
-import { AttestationService } from '../attestation.service';
import { Authorization } from '../authorization';
import { IdProvider } from '../idProvider';
-import { OAuthService } from 'angular-oauth2-oidc';
@Component({
@@ -46,9 +44,7 @@ export class EditIdentityComponent implements OnInit {
private oidcService: OpenIdService,
private namestoreService: NamestoreService,
private activatedRoute: ActivatedRoute,
- private router: Router,
- private attestationService: AttestationService,
- private oauthService: OAuthService) {}
+ private router: Router,) {}
ngOnInit() {
this.attributes = [];
@@ -58,7 +54,6 @@ export class EditIdentityComponent implements OnInit {
this.webfingerEmail = '';
this.emailNotFoundAlertClosed = true;
this.newIdProvider = new IdProvider ('', '', '');
- this.loadIdProviderFromLocalStorage();
this.loadAuthorizationsFromLocalStorage();
this.identity = new Identity('','');
this.newAttribute = new Attribute('', '', '', '', 'STRING', '');
@@ -630,54 +625,6 @@ export class EditIdentityComponent implements OnInit {
return "?";
}
- discoverIdProvider() {
- if (this.webfingerEmail == ''){
- return;
- }
- localStorage.setItem('userForAttestation', this.identity.name);
- this.isValidEmailforDiscovery();
- this.attestationService.getLink(this.webfingerEmail).subscribe (idProvider
=> {
- this.newIdProvider.url = (idProvider.links [0]).href;
- localStorage.setItem('newIdProviderURL', this.newIdProvider.url);
- this.newIdProvider.name =
this.getNewIdProviderName(this.newIdProvider.url);
- (idProvider.links.length > 1)? this.newIdProvider.logoutURL =
(idProvider.links [1]).href : this.newIdProvider.logoutURL =
this.newIdProvider.url;
- localStorage.setItem('newIdProviderLogoutURL',
this.newIdProvider.logoutURL);
- console.log(this.newIdProvider.url);
- this.webfingerEmail == '';
- },
- error => {
- if (error.status == 404){
- this.emailNotFoundAlertClosed = false;
- setTimeout(() => this.emailNotFoundAlertClosed = true, 20000);
- }
- this.webfingerEmail = '';
- console.log (error);
- });
- }
-
- isValidEmailforDiscovery(){
- if (!this.webfingerEmail.includes('@') && this.webfingerEmail != ''){
- return false;
- }
- return true;
- }
-
- newIdProviderDiscovered(){
- if (this.newIdProvider.url == ''){
- return false;
- }
- return true;
- }
-
- getNewIdProviderName(url: string){
- return url.split('//')[1];
- }
-
- loadIdProviderFromLocalStorage(){
- this.newIdProvider.url = localStorage.getItem("newIdProviderURL") || '';
- this.newIdProvider.name =
this.getNewIdProviderName(this.newIdProvider.url);
- this.newIdProvider.logoutURL =
localStorage.getItem("newIdProviderLogoutURL") || '';
- }
loadAuthorizationsFromLocalStorage(){
this.authorizations = [];
@@ -707,26 +654,6 @@ export class EditIdentityComponent implements OnInit {
});
}
- loginFhgAccount(){
- var authCodeFlowConfig =
this.attestationService.getOauthConfig(this.newIdProvider);
- this.oauthService.configure(authCodeFlowConfig);
- this.oauthService.loadDiscoveryDocumentAndLogin();
- }
-
-
- cancelLinking(){
- this.resetNewIdProvider();
- this.webfingerEmail = '';
- }
-
- resetNewIdProvider(){
- this.newIdProvider.url = '';
- this.newIdProvider.logoutURL = '';
- this.newIdProvider.name = '';
- localStorage.removeItem('newIdProviderURL');
- localStorage.removeItem('newIdProviderLogoutURL')
- }
-
setExperimental(set) {
if (set) {
localStorage.setItem('reclaimExperiments', 'enabled');
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [reclaim-ui] 229/459: fix, (continued)
- [reclaim-ui] 229/459: fix, gnunet, 2021/06/11
- [reclaim-ui] 238/459: improved error massage, gnunet, 2021/06/11
- [reclaim-ui] 225/459: added logout url to webfinger, gnunet, 2021/06/11
- [reclaim-ui] 212/459: Add typescript dependency to make modules happy., gnunet, 2021/06/11
- [reclaim-ui] 239/459: -fix expiration date display, gnunet, 2021/06/11
- [reclaim-ui] 231/459: maing, gnunet, 2021/06/11
- [reclaim-ui] 245/459: improved scope display, gnunet, 2021/06/11
- [reclaim-ui] 236/459: redirect after logout from idProvider, gnunet, 2021/06/11
- [reclaim-ui] 255/459: remove env, gnunet, 2021/06/11
- [reclaim-ui] 228/459: redirect to edit-attestation after linking account, gnunet, 2021/06/11
- [reclaim-ui] 237/459: moved IdProvider-Linking to edit-attestations,
gnunet <=
- [reclaim-ui] 242/459: more style, gnunet, 2021/06/11
- [reclaim-ui] 217/459: fixed attestation-save (already existing attestations were always added again), gnunet, 2021/06/11
- [reclaim-ui] 222/459: omejdn:api scope deleted, gnunet, 2021/06/11
- [reclaim-ui] 227/459: redirect now to edit-attestations/clientname should be edit-identity/clientname #20, gnunet, 2021/06/11
- [reclaim-ui] 203/459: yarn.lock, gnunet, 2021/06/11
- [reclaim-ui] 234/459: adding attestation works, gnunet, 2021/06/11
- [reclaim-ui] 214/459: package.json, gnunet, 2021/06/11
- [reclaim-ui] 240/459: scopes after idProviderDiscovery, gnunet, 2021/06/11
- [reclaim-ui] 244/459: fix, gnunet, 2021/06/11
- [reclaim-ui] 235/459: code duplicates removed, gnunet, 2021/06/11