mirror of
https://github.com/wassname/talk.git
synced 2026-07-26 13:37:38 +08:00
Hitting the delete route and deleting the token
This commit is contained in:
@@ -9,16 +9,12 @@ export type SignOffMutation = (input: SignOffInput) => Promise<void>;
|
||||
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);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user