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
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:
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user