Skip to content

Commit

Permalink
review: removed management classes
Browse files Browse the repository at this point in the history
  • Loading branch information
wyattjoh committed May 7, 2020
1 parent 2b32d05 commit 6e49a6a
Show file tree
Hide file tree
Showing 20 changed files with 233 additions and 341 deletions.
6 changes: 4 additions & 2 deletions src/core/client/account/local/initLocalState.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Environment } from "relay-runtime";

import { AuthState } from "coral-framework/lib/auth";
import { CoralContext } from "coral-framework/lib/bootstrap";
import { initLocalBaseState } from "coral-framework/lib/relay";

Expand All @@ -8,7 +9,8 @@ import { initLocalBaseState } from "coral-framework/lib/relay";
*/
export default async function initLocalState(
environment: Environment,
context: CoralContext
context: CoralContext,
auth?: AuthState
) {
initLocalBaseState(environment, context);
initLocalBaseState(environment, context, auth);
}
2 changes: 0 additions & 2 deletions src/core/client/admin/local/initLocalState.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Environment, RecordSource } from "relay-runtime";

import Auth from "coral-framework/lib/auth";
import { LOCAL_ID } from "coral-framework/lib/relay";
import {
createAccessToken,
Expand All @@ -14,7 +13,6 @@ let environment: Environment;
let source: RecordSource;

const context = {
auth: new Auth(),
localStorage: window.localStorage,
sessionStorage: window.sessionStorage,
};
Expand Down
8 changes: 5 additions & 3 deletions src/core/client/admin/local/initLocalState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { commitLocalUpdate, Environment } from "relay-runtime";

import { REDIRECT_PATH_KEY } from "coral-admin/constants";
import { clearHash, getParamsFromHash } from "coral-framework/helpers";
import { AuthState, updateAccessToken } from "coral-framework/lib/auth";
import { CoralContext } from "coral-framework/lib/bootstrap";
import { initLocalBaseState, LOCAL_ID } from "coral-framework/lib/relay";

Expand All @@ -10,7 +11,8 @@ import { initLocalBaseState, LOCAL_ID } from "coral-framework/lib/relay";
*/
export default async function initLocalState(
environment: Environment,
context: CoralContext
context: CoralContext,
auth?: AuthState
) {
// Initialize the redirect path in case we don't need to redirect somewhere.
let redirectPath: string | null = null;
Expand All @@ -29,7 +31,7 @@ export default async function initLocalState(

// If there was an access token, store it.
if (params.accessToken) {
context.auth.set(params.accessToken);
auth = updateAccessToken(params.accessToken);
}

// As we are in the middle of an auth flow (given that there was something
Expand All @@ -42,7 +44,7 @@ export default async function initLocalState(
await context.localStorage.setItem(REDIRECT_PATH_KEY, "");
}

initLocalBaseState(environment, context);
initLocalBaseState(environment, context, auth);

commitLocalUpdate(environment, (s) => {
const localRecord = s.get(LOCAL_ID)!;
Expand Down
2 changes: 0 additions & 2 deletions src/core/client/auth/local/initLocalState.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Environment, RecordSource } from "relay-runtime";

import Auth from "coral-framework/lib/auth";
import { LOCAL_ID } from "coral-framework/lib/relay";
import {
createAccessToken,
Expand All @@ -14,7 +13,6 @@ let environment: Environment;
let source: RecordSource;

const context = {
auth: new Auth(),
localStorage: window.localStorage,
sessionStorage: window.sessionStorage,
};
Expand Down
9 changes: 5 additions & 4 deletions src/core/client/auth/local/initLocalState.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable prettier/prettier */
import { commitLocalUpdate, Environment } from "relay-runtime";

import { parseQuery } from "coral-common/utils";
import { getParamsFromHashAndClearIt } from "coral-framework/helpers";
import { AuthState, updateAccessToken } from "coral-framework/lib/auth";
import { CoralContext } from "coral-framework/lib/bootstrap";
import { initLocalBaseState, LOCAL_ID } from "coral-framework/lib/relay";

Expand All @@ -11,15 +11,16 @@ import { initLocalBaseState, LOCAL_ID } from "coral-framework/lib/relay";
*/
export default async function initLocalState(
environment: Environment,
context: CoralContext
context: CoralContext,
auth?: AuthState
) {
const { error = null, accessToken = null } = getParamsFromHashAndClearIt();

if (accessToken) {
context.auth.set(accessToken);
auth = updateAccessToken(accessToken);
}

initLocalBaseState(environment, context);
initLocalBaseState(environment, context, auth);

commitLocalUpdate(environment, (s) => {
const localRecord = s.get(LOCAL_ID)!;
Expand Down
72 changes: 0 additions & 72 deletions src/core/client/framework/lib/auth/Auth.ts

This file was deleted.

122 changes: 0 additions & 122 deletions src/core/client/framework/lib/auth/JWTManager.ts

This file was deleted.

Loading

0 comments on commit 6e49a6a

Please sign in to comment.