MCPcopy Create free account
hub / github.com/codicocodes/speedtyper.dev / logout

Function logout

packages/webapp-next/common/api/auth.ts:19–41  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17};
18
19export const logout = async () => {
20 const serverUrl = getExperimentalServerUrl();
21 const authUrl = `${serverUrl}/api/auth`;
22 return fetch(authUrl, {
23 method: "DELETE",
24 credentials: "include",
25 }).then(async () => {
26 const prevUserId = useUserStore.getState().id;
27 const user = await fetchUser();
28 useUserStore.setState((state) => ({
29 ...state,
30 ...user,
31 avatarUrl: undefined,
32 }));
33 useGameStore.setState((state) => {
34 return {
35 ...state,
36 owner: state.owner === prevUserId ? user.id : state.owner,
37 };
38 });
39 useGameStore.getState().game?.reconnect();
40 });
41};

Callers 1

ProfileModalFunction · 0.90

Calls 4

getExperimentalServerUrlFunction · 0.90
fetchUserFunction · 0.90
getStateMethod · 0.80
reconnectMethod · 0.80

Tested by

no test coverage detected