Skip to content

Commit

Permalink
Merge pull request #6 from alcheng005/main
Browse files Browse the repository at this point in the history
Edited comments and fixed SessionManager
  • Loading branch information
BAlexanderNance committed Feb 9, 2021
2 parents bdb4e49 + e6e83ca commit ebdf3e1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 89 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
### Dashport
# Dashport
76 changes: 0 additions & 76 deletions lib/dashport.js

This file was deleted.

20 changes: 10 additions & 10 deletions lib/sessionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import { OakContext, UserProfile } from './types.ts';
* @param {string} framework - The name of the server framework to be used
*/
class SessionManager {
logIn: Function;
logOut: Function;
isAuthenticated: Function;
public logIn: Function;
public logOut: Function;
public isAuthenticated: Function;

constructor(framework: string): void {
this.logIn = _logInDecider(framework);
this.logOut = _logOutDecider(framework);
this.isAuthenticated = _isAuthenticatedDecider(framework);
this.logIn = this._logInDecider(framework);
this.logOut = this._logOutDecider(framework);
this.isAuthenticated = this._isAuthenticatedDecider(framework);
}

/**
Expand All @@ -39,7 +39,7 @@ class SessionManager {
_logInDecider(framework: string): Function {
if (framework = 'oak') {
return function(ctx: OakContext, serializedId: string): void {
ctx.state.dashport.session = { userId: serializedId };
ctx.state._dashport.session = { userId: serializedId };
}
}

Expand All @@ -57,7 +57,7 @@ class SessionManager {
_logOutDecider(framework: string): Function {
if (framework = 'oak') {
return function(ctx: OakContext): void {
delete ctx.state.dashport.session
delete ctx.state._dashport.session
}
}

Expand All @@ -78,8 +78,8 @@ class SessionManager {
_isAuthenticatedDecider(framework: string): Function {
if (framework = 'oak') {
return function(ctx: OakContext, serializedId: string): boolean {
if (ctx.state.dashport.session) {
if (serializedId === ctx.state.dashport.session.userId) return true;
if (ctx.state._dashport.session) {
if (serializedId === ctx.state._dashport.session.userId) return true;
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export interface OakContext {

/**
* Different OAuths will return different user information in different
* structures. Dashport breaks down and reconstructs the user info into the
* standardized UserProfile below
* structures. Dashport strategies should break down and reconstruct the user
* info into the standardized UserProfile below
*/
export interface UserProfile {
// the ID Dashport has come up with for a user
Expand Down

0 comments on commit ebdf3e1

Please sign in to comment.