Skip to content

Commit

Permalink
Disconnect auto + start restyle
Browse files Browse the repository at this point in the history
  • Loading branch information
MacaronFR committed Jun 30, 2024
1 parent 361cd2d commit 0013f42
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/frontend/src/auth/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export const AuthContextProvider = ({ children }: Props) => {
localStorage.removeItem("deviceId");
setToken(undefined);
user.clean();
document.location.assign("/login");
}, []);

externalDisconnect = disconnect;
Expand Down
3 changes: 3 additions & 0 deletions packages/frontend/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
* {
font-family: Inter, sans-serif;
font-weight: 600;
scroll-behavior: smooth;
scrollbar-width: thin;
scrollbar-color: rgb(var(--color-base)) transparent;
}

@layer base {
Expand Down
3 changes: 3 additions & 0 deletions packages/frontend/src/utils/useApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
} from "preact/hooks";
import { backendBaseUrl } from "../config";
import { TAuthInfo } from "../auth/types";
import { externalDisconnect } from "../auth/context.tsx";

interface UseApiOptions {
method?: string,
Expand Down Expand Up @@ -118,6 +119,8 @@ export async function apiRaw<T>(url: string, type?: string, options?: ApiRawOpti
localStorage.setItem("deviceId", res.data.deviceId);
localStorage.setItem("token", res.data.token);
return apiRaw<T>(url, type, options);
} else if (res.status === 403) {
externalDisconnect();
} else {
return {
status: response.status,
Expand Down

0 comments on commit 0013f42

Please sign in to comment.