ФУНКЦИИ - МЕЖПРОЕКТНАЯ КОММУНИКАЦИЯ: Plane live access и logout handoff

This commit is contained in:
DCCONSTRUCTIONS
2026-05-04 18:54:21 +03:00
parent 55318f14e5
commit 3b13e5be52
15 changed files with 435 additions and 36 deletions
@@ -8,6 +8,8 @@
import type { AxiosInstance, AxiosRequestConfig } from "axios";
import axios from "axios";
import { buildNodeDCOIDCLoginUrl, getCurrentRelativePath, shouldUseNodeDCOIDC } from "@/helpers/nodedc-auth";
export abstract class APIService {
protected baseURL: string;
private axiosInstance: AxiosInstance;
@@ -26,9 +28,17 @@ export abstract class APIService {
this.axiosInstance.interceptors.response.use(
(response) => response,
(error) => {
if (error.response && error.response.status === 401) {
const status = error.response?.status;
const responseError = error.response?.data?.error;
if (status === 401 || (status === 403 && responseError === "nodedc_access_revoked")) {
const currentPath = window.location.pathname;
window.location.replace(`/${currentPath ? `?next_path=${currentPath}` : ``}`);
if (shouldUseNodeDCOIDC()) {
window.location.replace(buildNodeDCOIDCLoginUrl(getCurrentRelativePath()));
} else {
window.location.replace(`/${currentPath ? `?next_path=${currentPath}` : ``}`);
}
}
return Promise.reject(error);
}