feat(auth): call POST /v1/admin/logout before clear storage. Fixes EventHub/EventHubFrontAdmin#43
CI / test (push) Successful in 52s
CI / push-image (push) Successful in 1m38s
CI / deploy-ift (push) Successful in 8s
CI / ci-done (push) Successful in 0s
CI / e2e-ift (push) Successful in 21s
CI / deploy-stage (push) Successful in 1m30s
CI / e2e-stage (push) Successful in 25s

This commit is contained in:
2026-08-14 20:23:35 +03:00
parent 9e46a891b8
commit a1f6ba1c91
2 changed files with 11 additions and 0 deletions
+3
View File
@@ -16,6 +16,9 @@ export const authApi = {
const { data } = await apiClient.get('/v1/admin/me');
return data;
},
logout: async (refreshToken: string): Promise<void> => {
await apiClient.post('/v1/admin/logout', { refresh_token: refreshToken });
},
updateMe: async (payload: Partial<Admin>): Promise<Admin> => {
const { data } = await apiClient.put('/v1/admin/me', payload);
return data;
+8
View File
@@ -37,6 +37,14 @@ export const useAuthStore = create<AuthState>((set) => ({
},
logout: async () => {
const refresh = localStorage.getItem(REFRESH_TOKEN_KEY);
if (refresh) {
try {
await authApi.logout(refresh);
} catch {
// сеть/401 — всё равно чистим локально
}
}
localStorage.removeItem(ACCESS_TOKEN_KEY);
localStorage.removeItem(REFRESH_TOKEN_KEY);
useMetricsStore.getState().reset();