Fix UserBox

This commit is contained in:
Chi Vinh Le
2018-08-24 11:17:09 +02:00
parent 5501ee7832
commit 65a212b531
12 changed files with 70 additions and 114 deletions
@@ -0,0 +1,14 @@
import { Environment } from "relay-runtime";
import { TalkContext } from "talk-framework/lib/bootstrap";
import { createMutationContainer } from "talk-framework/lib/relay";
import signOut from "../rest/signOut";
import { commit as setAuthToken } from "./SetAuthTokenMutation";
export type SignOutMutation = () => Promise<void>;
export async function commit(environment: Environment, ctx: TalkContext) {
await setAuthToken(environment, { authToken: "" }, ctx);
await signOut(ctx.rest);
}
export const withSignOutMutation = createMutationContainer("signOut", commit);
@@ -3,3 +3,4 @@ export {
SetAuthTokenMutation,
SetAuthTokenInput,
} from "./SetAuthTokenMutation";
export { withSignOutMutation, SignOutMutation } from "./SignOutMutation";
+1 -1
View File
@@ -1,3 +1,3 @@
export { default as signIn, SignInInput } from "./signIn";
export { default as signUp, SignUpInput } from "./signUp";
export { default as signOff } from "./signOff";
export { default as signOut } from "./signOut";
@@ -1,7 +0,0 @@
import { RestClient } from "../lib/rest";
export default function signOff(rest: RestClient) {
return rest.fetch("/tenant/auth/local", {
method: "DELETE",
});
}
@@ -0,0 +1,7 @@
import { RestClient } from "../lib/rest";
export default function signOut(rest: RestClient) {
return rest.fetch("/tenant/auth", {
method: "DELETE",
});
}