Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edited comments and fixed SessionManager #6

Merged
merged 4 commits into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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