feat: added initial implementation

This commit is contained in:
2026-03-14 23:30:56 +03:00
parent 8b626a940e
commit 2a8b6a7b62
19 changed files with 964 additions and 79 deletions
+7 -2
View File
@@ -1,5 +1,5 @@
import { createContext, useCallback, useContext, useEffect, useState } from "react";
import { apiGet, apiPost } from "../api/client";
import { apiGet, apiPost, ApiError } from "../api/client";
const STORAGE_ACCESS = "auth_access";
const STORAGE_REFRESH = "auth_refresh";
@@ -50,7 +50,12 @@ export function AuthProvider({ children }) {
setUser(data);
setLoading(false);
})
.catch(() => {
.catch((err) => {
const status = err instanceof ApiError ? err.status : err?.status;
if (status !== 401) {
setLoading(false);
return;
}
// Token invalid, try refresh
if (!refreshToken) {
logout();