diff --git a/src/core/client/auth/mutations/SignOffMutation.ts b/src/core/client/auth/mutations/SignOffMutation.ts index b926960df..dcaadfd8f 100644 --- a/src/core/client/auth/mutations/SignOffMutation.ts +++ b/src/core/client/auth/mutations/SignOffMutation.ts @@ -9,16 +9,12 @@ export type SignOffMutation = (input: SignOffInput) => Promise; export async function commit( environment: Environment, input: SignOffInput, - { rest, postMessage }: TalkContext + { rest, localStorage }: TalkContext ) { - try { - await signOff(rest, input); - console.log("signing off"); - // postMessage.send("setAuthToken", result.token, window.opener); - // window.close(); - } catch (err) { - // postMessage.send("authError", err.toString(), window.opener); - } + await signOff(rest, input); + // tslint:disable-next-line:no-console + console.log("Signing off"); + localStorage.removeItem("authToken"); } export const withSignOffMutation = createMutationContainer("signOff", commit); diff --git a/src/core/client/framework/lib/rest.ts b/src/core/client/framework/lib/rest.ts index 790465798..9548febea 100644 --- a/src/core/client/framework/lib/rest.ts +++ b/src/core/client/framework/lib/rest.ts @@ -19,12 +19,13 @@ const buildOptions = (inputOptions: RequestInit = {}) => { const handleResp = (res: Response) => { if (res.status > 399) { - return res.json().then((err: any) => { - // TODO: sync error handling with server. - const message = err.message || err.error || res.status; - const error = new Error(message); - throw error; - }); + return res.text(); + // TODO (bc): sync error handling with server. + // return res.json().then((err: any) => { + // const message = err.message || err.error || res.status; + // const error = new Error(message); + // throw error; + // }); } else if (res.status === 204) { return res.text(); } else { diff --git a/src/core/server/app/router.ts b/src/core/server/app/router.ts index 6c06f8848..75b195ab3 100644 --- a/src/core/server/app/router.ts +++ b/src/core/server/app/router.ts @@ -69,11 +69,16 @@ function createNewAuthRouter(app: AppOptions, options: RouterOptions) { express.json(), wrapAuthn(options.passport, app.signingConfig, "local") ); + + // TODO (bc) - add delete user serverside + router.delete("/local", express.json()); + router.post( "/local/signup", express.json(), signupHandler({ db: app.mongo, signingConfig: app.signingConfig }) ); + router.post("/sso", wrapAuthn(options.passport, app.signingConfig, "sso")); router.get("/oidc", wrapAuthn(options.passport, app.signingConfig, "oidc")); router.get(