fix: allow refresh tokens in AuthMiddleware for refresh route and dispatch auth_error on 401s to force login redirect
All checks were successful
Automated Container Build / build-and-push (push) Successful in 1m23s
All checks were successful
Automated Container Build / build-and-push (push) Successful in 1m23s
This commit is contained in:
parent
4c8e6b814c
commit
fbad71cbf2
3 changed files with 19 additions and 2 deletions
|
|
@ -81,6 +81,9 @@ class ApiClient {
|
|||
}
|
||||
|
||||
if (!response.ok && endpoint !== '/api/auth/refresh') {
|
||||
if (response.status === 401) {
|
||||
if (typeof window !== 'undefined') window.dispatchEvent(new Event('auth_error'));
|
||||
}
|
||||
let errorMsg = `HTTP ${response.status}`;
|
||||
try {
|
||||
const errData = await response.clone().json();
|
||||
|
|
@ -111,6 +114,7 @@ class ApiClient {
|
|||
}
|
||||
|
||||
this.clearTokens();
|
||||
if (typeof window !== 'undefined') window.dispatchEvent(new Event('auth_error'));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in a new issue