mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-09-22 16:00:51 +00:00
fix: silence csrf forbidden toast (#12461)
This commit is contained in:
@@ -18,6 +18,11 @@ const config = {
|
||||
withCredentials: true,
|
||||
};
|
||||
|
||||
const isCsrfForbidden = (response?: AxiosResponse<any>) => {
|
||||
const message = response?.data?.message;
|
||||
return typeof message === 'string' && message.toLowerCase().includes('csrf token invalid');
|
||||
};
|
||||
|
||||
class RequestHttp {
|
||||
service: AxiosInstance;
|
||||
public constructor(config: AxiosRequestConfig) {
|
||||
@@ -118,6 +123,9 @@ class RequestHttp {
|
||||
router.push({ name: 'Expired' });
|
||||
return;
|
||||
case 403:
|
||||
if (isCsrfForbidden(response)) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
if (response.data && response.data['message']) {
|
||||
MsgError(response.data['message']);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user