mirror of
https://github.com/tubearchivist/tubearchivist.git
synced 2025-03-14 18:00:13 +00:00
Refac use Routes constant for logout
This commit is contained in:
parent
daf09fcc33
commit
6b87f2d0fc
@ -3,6 +3,7 @@ import getApiUrl from '../configuration/getApiUrl';
|
||||
import getFetchCredentials from '../configuration/getFetchCredentials';
|
||||
import logOut from '../api/actions/logOut';
|
||||
import getCookie from './getCookie';
|
||||
import Routes from '../configuration/routes/RouteList';
|
||||
|
||||
export interface ApiClientOptions extends Omit<RequestInit, 'body'> {
|
||||
method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
||||
@ -31,13 +32,13 @@ const APIClient = async (
|
||||
// Handle common errors
|
||||
if (response.status === 401) {
|
||||
logOut();
|
||||
window.location.href = '/login';
|
||||
window.location.href = Routes.Login;
|
||||
throw new Error('Unauthorized: Redirecting to login.');
|
||||
}
|
||||
|
||||
if (response.status === 403) {
|
||||
logOut();
|
||||
window.location.href = '/login';
|
||||
window.location.href = Routes.Login;
|
||||
throw new Error('Forbidden: Access denied.');
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user