mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-17 06:35:54 +08:00
chore: interceptor is updated
This commit is contained in:
parent
22454abc4a
commit
039201acae
@ -40,7 +40,7 @@ const afterLogin = async (
|
|||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (getUserResponse.statusCode === 200) {
|
if (getUserResponse.statusCode === 200 && getUserResponse.payload) {
|
||||||
store.dispatch<AppActions>({
|
store.dispatch<AppActions>({
|
||||||
type: LOGGED_IN,
|
type: LOGGED_IN,
|
||||||
payload: {
|
payload: {
|
||||||
|
@ -35,7 +35,6 @@ const interceptorRejected = async (
|
|||||||
try {
|
try {
|
||||||
if (axios.isAxiosError(value) && value.response) {
|
if (axios.isAxiosError(value) && value.response) {
|
||||||
const { response } = value;
|
const { response } = value;
|
||||||
console.log(response);
|
|
||||||
// reject the refresh token error
|
// reject the refresh token error
|
||||||
if (response.status === 401 && response.config.url !== '/login') {
|
if (response.status === 401 && response.config.url !== '/login') {
|
||||||
const response = await loginApi({
|
const response = await loginApi({
|
||||||
@ -43,12 +42,13 @@ const interceptorRejected = async (
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (response.statusCode === 200) {
|
if (response.statusCode === 200) {
|
||||||
await afterLogin(
|
const user = await afterLogin(
|
||||||
response.payload.userId,
|
response.payload.userId,
|
||||||
response.payload.accessJwt,
|
response.payload.accessJwt,
|
||||||
response.payload.refreshJwt,
|
response.payload.refreshJwt,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (user) {
|
||||||
const reResponse = await axios(
|
const reResponse = await axios(
|
||||||
`${value.config.baseURL}${value.config.url?.substring(1)}`,
|
`${value.config.baseURL}${value.config.url?.substring(1)}`,
|
||||||
{
|
{
|
||||||
@ -71,6 +71,10 @@ const interceptorRejected = async (
|
|||||||
return await Promise.reject(reResponse);
|
return await Promise.reject(reResponse);
|
||||||
}
|
}
|
||||||
Logout();
|
Logout();
|
||||||
|
|
||||||
|
return await Promise.reject(value);
|
||||||
|
}
|
||||||
|
Logout();
|
||||||
}
|
}
|
||||||
|
|
||||||
// when refresh token is expired
|
// when refresh token is expired
|
||||||
@ -80,7 +84,7 @@ const interceptorRejected = async (
|
|||||||
}
|
}
|
||||||
return await Promise.reject(value);
|
return await Promise.reject(value);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return Promise.reject(value);
|
return await Promise.reject(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ const getUser = async (
|
|||||||
return {
|
return {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
error: null,
|
error: null,
|
||||||
message: response.data.status,
|
message: 'Success',
|
||||||
payload: response.data,
|
payload: response.data,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user