mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-11 03:24:16 +00:00
improve error handling on handleAfterRequest
This commit is contained in:
parent
d26e5a78f5
commit
160e00b5a9
@ -153,7 +153,7 @@ export default class ApiCore extends Core {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleAfterRequest = async (data, callback) => {
|
handleAfterRequest = async (data, callback) => {
|
||||||
// handle 401 responses
|
// handle 401, 403 responses
|
||||||
if (data instanceof Error) {
|
if (data instanceof Error) {
|
||||||
if (data.response.status === 401) {
|
if (data.response.status === 401) {
|
||||||
// check if the server issue a refresh token on data
|
// check if the server issue a refresh token on data
|
||||||
@ -164,12 +164,17 @@ export default class ApiCore extends Core {
|
|||||||
await this.handleRegenerationEvent(data.response.data.refreshToken)
|
await this.handleRegenerationEvent(data.response.data.refreshToken)
|
||||||
|
|
||||||
return await callback()
|
return await callback()
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
// check if route is from "session" namespace
|
||||||
|
if (data.config.url.includes("/session")) {
|
||||||
return window.app.eventBus.emit("session.invalid", "Session expired, but the server did not issue a refresh token")
|
return window.app.eventBus.emit("session.invalid", "Session expired, but the server did not issue a refresh token")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (data.response.status === 403) {
|
if (data.response.status === 403) {
|
||||||
return window.app.eventBus.emit("session.invalid", "Session not valid or not existent")
|
if (data.config.url.includes("/session")) {
|
||||||
|
return window.app.eventBus.emit("session.invalid", "Session not valid or not existent")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user