From 4d682616367f720fd49f7194d0e63fb3cb928d8f Mon Sep 17 00:00:00 2001 From: schettn Date: Fri, 12 Jun 2020 20:36:28 +0200 Subject: [PATCH 1/2] Correct profile data interface ProfileData does not include the attributes directly, instead there are in a object called `profile`. This was missing and therefore added. --- src/templates/snek/gql/tasks/user.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/templates/snek/gql/tasks/user.ts b/src/templates/snek/gql/tasks/user.ts index 2ce2131..274ee7e 100644 --- a/src/templates/snek/gql/tasks/user.ts +++ b/src/templates/snek/gql/tasks/user.ts @@ -31,15 +31,17 @@ interface CacheData { * data. */ interface ProfileData { - username: string; - firstName: string; - lastName: string; - email: string; - verified: string; - platformData: string; - sources: string; - bids: string; - tids: string; + profile: { + username: string; + firstName: string; + lastName: string; + email: string; + verified: string; + platformData: string; + sources: string; + bids: string; + tids: string; + }; } /** From 6b3e938dafc80602f7fa31bdcdb495d587fdad28 Mon Sep 17 00:00:00 2001 From: schettn Date: Wed, 29 Jul 2020 15:47:46 +0200 Subject: [PATCH 2/2] Extract Session Cookie Handling Now the cookie token handling takes place in a own session which can be extended. --- src/session/sessions.ts | 47 +++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/src/session/sessions.ts b/src/session/sessions.ts index 10e12d6..33cdc18 100644 --- a/src/session/sessions.ts +++ b/src/session/sessions.ts @@ -63,31 +63,19 @@ class GithubSession extends Session { } } -/** @class A SNEK SubSession */ -class SnekSession extends Session { +/** @class CookieSession extends token session handling with cookies */ +class CookieSession extends Session { refreshTokenName: string = "refresh"; - /* Define tasks */ - public tasks: SnekTasks; /** - * Initializes a SNEK session. + * Initializes a cookie session. * * @constructor * @author Nico Schett * @param {string} sId A session name - * @param {Endpoint} ep A endpoint - * @param {SnekTemplate} template A template set */ - constructor( - sId: string, - public ep: ApolloEndpoint, - public template: SnekTemplate - ) { + constructor(sId: string) { super(sId); - - this.tokenName = sId + "-" + this.tokenName; - this.refreshTokenName = sId + "-" + this.refreshTokenName; - this.tasks = new SnekTasks(this); } //> Getter @@ -149,6 +137,33 @@ class SnekSession extends Session { Cookies.remove(this.refreshTokenName); } } +} + +/** @class A SNEK SubSession */ +class SnekSession extends CookieSession { + /* Define tasks */ + public tasks: SnekTasks; + + /** + * Initializes a SNEK session. + * + * @constructor + * @author Nico Schett + * @param {string} sId A session name + * @param {Endpoint} ep A endpoint + * @param {SnekTemplate} template A template set + */ + constructor( + sId: string, + public ep: ApolloEndpoint, + public template: SnekTemplate + ) { + super(sId); + + this.tokenName = sId + "-" + this.tokenName; + this.refreshTokenName = sId + "-" + this.refreshTokenName; + this.tasks = new SnekTasks(this); + } //> Methods /**