[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[reclaim-ui] 210/459: new Attestation created
From: |
gnunet |
Subject: |
[reclaim-ui] 210/459: new Attestation created |
Date: |
Fri, 11 Jun 2021 23:25:02 +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 5fc7dd02af42f2a8f57c5a4181e7dade29ae0061
Author: anna wimbauer <anna.wibauer@gmx.de>
AuthorDate: Wed Jun 10 22:19:14 2020 +0200
new Attestation created
---
src/app/accessToken.ts | 4 +
src/app/edit-identity/edit-identity.component.html | 4 +
src/app/edit-identity/edit-identity.component.ts | 104 +++++++++++++++------
3 files changed, 81 insertions(+), 31 deletions(-)
diff --git a/src/app/accessToken.ts b/src/app/accessToken.ts
new file mode 100644
index 0000000..d14e7e7
--- /dev/null
+++ b/src/app/accessToken.ts
@@ -0,0 +1,4 @@
+export interface AccessToken {
+ idProvider: string;
+ accessToken: string;
+}
\ No newline at end of file
diff --git a/src/app/edit-identity/edit-identity.component.html
b/src/app/edit-identity/edit-identity.component.html
index 6bed8eb..8221297 100644
--- a/src/app/edit-identity/edit-identity.component.html
+++ b/src/app/edit-identity/edit-identity.component.html
@@ -170,6 +170,10 @@
<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>
+ <!--Save account-->
+ <button *ngIf="isExperimental() && newIdProviderDiscovered() &&
grantedAccessToIdProvider()" class="btn btn-primary mb-4 fhg-link"
(click)="saveIdProviderinLocalStorage()">
+ <span class="fa fa-user"></span> Save {{getNewIdProviderName()}} Account
+ </button>
<hr/>
diff --git a/src/app/edit-identity/edit-identity.component.ts
b/src/app/edit-identity/edit-identity.component.ts
index 6047ba5..1205a43 100644
--- a/src/app/edit-identity/edit-identity.component.ts
+++ b/src/app/edit-identity/edit-identity.component.ts
@@ -13,6 +13,7 @@ import { from, forkJoin, EMPTY } from 'rxjs';
import {WebfingerService} from '../webfinger.service';
import { OAuthService } from 'angular-oauth2-oidc';
import { OauthHelperService } from '../oauth-helper.service'
+import { AccessToken } from '../accessToken';
@Component({
@@ -34,8 +35,7 @@ export class EditIdentityComponent implements OnInit {
requestedAttested: Attribute[];
optionalAttested: Attribute[];
webfingerEmail: string;
- idProvider: any[];
- accessToken: any[];
+ accessToken: AccessToken[];
newIdProvider: string;
emailNotFoundAlertClosed: boolean;
@@ -58,7 +58,7 @@ export class EditIdentityComponent implements OnInit {
this.webfingerEmail = '';
this.newIdProvider = '';
this.emailNotFoundAlertClosed = true;
- this.loadIdProviderAndAccessTokenFromLocalStorage();
+ this.loadAccessTokenFromLocalStorage();
this.identity = new Identity('','');
this.newAttribute = new Attribute('', '', '', '', 'STRING', '');
this.newAttested = new Attribute('', '', '', '', 'STRING', '');
@@ -626,6 +626,7 @@ export class EditIdentityComponent implements OnInit {
}
getFhGAttestation() {
+ this.logOutFromOauthService();
if (this.webfingerEmail == ''){
return;
}
@@ -654,19 +655,14 @@ export class EditIdentityComponent implements OnInit {
}
discoveredIdProviderExistsAlready(){
- if (this.idProvider.includes(this.newIdProvider)){
- return true;
- }
+ this.accessToken.forEach(token => {
+ if (token.idProvider == this.newIdProvider){
+ return true;
+ }
+ });
return false;
}
- idProviderFound(){
- if (localStorage.getItem('idProvider') == null){
- return false;
- }
- return true;
- }
-
newIdProviderDiscovered(){
if (this.newIdProvider == ''){
return false;
@@ -682,15 +678,7 @@ export class EditIdentityComponent implements OnInit {
var authCodeFlowConfig =
this.oauthHelperService.getOauthConfig(this.newIdProvider);
this.oauthService.configure(authCodeFlowConfig);
this.oauthService.loadDiscoveryDocumentAndLogin();
- if (this.getId() == null){
- console.log("error: can't get id");
- return;
- }
- this.idProvider.push(this.newIdProvider);
- this.newIdProvider = '';
- 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);
@@ -703,6 +691,19 @@ export class EditIdentityComponent implements OnInit {
});; */
}
+ saveIdProviderinLocalStorage(){
+ const newAccessToken: AccessToken = {
+ idProvider: this.newIdProvider,
+ accessToken: this.getAccessToken(),
+ }
+ this.accessToken.push(newAccessToken);
+ localStorage.setItem('idProvider:' + this.newIdProvider,
this.getAccessToken());
+ //addAttestation() --> idProvider needs to be saved in gnunet? Why
save IdProvider in LocalStorage if I store attestations with value on
gnunetserver?
+ const newAttestation = new Attestation (this.newIdProvider,
this.getId().id, 'STRING', 'openID', this.newIdProvider,
this.getAttestationExpiration(), this.getAttestationAttributes());
+ this.attestations.push(newAttestation);
+ this.newIdProvider = '';
+ }
+
getId (): any{
return this.oauthService.getIdentityClaims();
}
@@ -711,21 +712,44 @@ export class EditIdentityComponent implements OnInit {
return this.oauthService.getAccessToken();
}
- loadIdProviderAndAccessTokenFromLocalStorage(){
- this.idProvider = [];
+ grantedAccessToIdProvider(){
+ if (this.oauthService.hasValidAccessToken()){
+ console.log("logged in");
+ return true;
+ };
+ return false;
+ }
+
+ loadAccessTokenFromLocalStorage(){
this.accessToken = [];
- if (!this.idProviderFound()){
+ var potentialIdProviders = Object.keys(localStorage);
+ potentialIdProviders.forEach(element => {
+ if (element.includes('idProvider')){
+ var idProvider = element.replace('idProvider:', '');
+ const newAccessToken: AccessToken = {
+ idProvider: idProvider,
+ accessToken: localStorage.getItem(idProvider),
+ }
+ this.accessToken.push(newAccessToken);
+ }
+
+ });
+ }
+
+ logOutFromOauthService(){
+ if (!this.oauthService.hasValidAccessToken()){
return;
}
- const idProviderAndAccessToken =
localStorage.getItem('idProvider').split('{');
- idProviderAndAccessToken.forEach(element => {
- this.idProvider.push(element.split(';')[0]);
- this.accessToken.push((element.split(';')[1]).split('}')[0]);
- });
+ this.oauthService.logOut();
+ if (!this.oauthService.hasValidAccessToken()){
+ console.log("logged out from outhService");
+ }
}
+
+
addAttestation() {
- const newAttestation = new Attestation (this.getId().name,
this.getId().id, this.getId().type, 'openID', this.newIdProvider,
this.getAttestationExpiration(), []);
+ const newAttestation = new Attestation (this.newIdProvider,
this.newIdProvider, 'STRING', 'openID', this.newIdProvider,
this.getAttestationExpiration(), this.getAttestationAttributes());
const promises = [];
let i;
if (undefined !== this.attestations) {
@@ -744,6 +768,24 @@ export class EditIdentityComponent implements OnInit {
return this.oauthService.getIdTokenExpiration()
}
+ getAttestationAttributes(): Attribute[]{
+ var attestationAttributes: Attribute [] = [];
+ const attributesObject = this.getId();
+ Object.keys(attributesObject).forEach (attributeKey => {
+ console.log(attributeKey);
+ var tempAttribute: Attribute = {
+ name: attributeKey,
+ id: this.newIdProvider, //Don't think this is correct id
+ attestation: this.newIdProvider,
+ value: attributesObject[attributeKey],
+ type: 'STRING',
+ flag: '1',
+ }
+ attestationAttributes.push(tempAttribute);
+ });
+ return attestationAttributes;
+ }
+
setExperimental(set) {
if (set) {
localStorage.setItem('reclaimExperiments', 'enabled');
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [reclaim-ui] 188/459: add expiration, (continued)
- [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, 2021/06/11
- [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 <=
- [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
- [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