[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.
- [reclaim-ui] 204/459: merge yarn.lock, (continued)
- [reclaim-ui] 204/459: merge yarn.lock, gnunet, 2021/06/11
- [reclaim-ui] 192/459: minor fixes, gnunet, 2021/06/11
- [reclaim-ui] 195/459: fix parsing claims parameter, gnunet, 2021/06/11
- [reclaim-ui] 218/459: login works properly, gnunet, 2021/06/11
- [reclaim-ui] 188/459: add expiration, gnunet, 2021/06/11
- [reclaim-ui] 198/459: back to where it should be, gnunet, 2021/06/11
- [reclaim-ui] 201/459: started integrating oauthservice for attestation, gnunet, 2021/06/11
- [reclaim-ui] 221/459: logout on server side works #19, gnunet, 2021/06/11
- [reclaim-ui] 220/459: attestation name duplication prevented + trying to logout on serverside, gnunet, 2021/06/11
- [reclaim-ui] 224/459: random token request deleted, gnunet, 2021/06/11
- [reclaim-ui] 209/459: trying to save accesstoken in localStorage,
gnunet <=
- [reclaim-ui] 219/459: merge webfinger-service and oauth-helper-service into attestation-service, gnunet, 2021/06/11
- [reclaim-ui] 230/459: fix webfinger, gnunet, 2021/06/11
- [reclaim-ui] 226/459: nothing important, gnunet, 2021/06/11
- [reclaim-ui] 210/459: new Attestation created, gnunet, 2021/06/11
- [reclaim-ui] 202/459: update dependencies, gnunet, 2021/06/11
- [reclaim-ui] 196/459: issuer discoverable, gnunet, 2021/06/11
- [reclaim-ui] 213/459: Attestation is added after account is linked, gnunet, 2021/06/11
- [reclaim-ui] 215/459: merge, gnunet, 2021/06/11
- [reclaim-ui] 211/459: update dependencies, gnunet, 2021/06/11
- [reclaim-ui] 223/459: button label changed, gnunet, 2021/06/11