Skip to content

Commit

Permalink
Merge pull request #54 from snek-at/improve-structure-aa1
Browse files Browse the repository at this point in the history
Improve structure aa1 to master
  • Loading branch information
schettn authored Jul 29, 2020
2 parents b06a8e8 + 6b3e938 commit 250161b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 25 deletions.
47 changes: 31 additions & 16 deletions src/session/sessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
* @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
Expand Down Expand Up @@ -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 <[email protected]>
* @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
/**
Expand Down
20 changes: 11 additions & 9 deletions src/templates/snek/gql/tasks/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
}

/**
Expand Down

0 comments on commit 250161b

Please sign in to comment.