forked from Archives/Athou_commafeed
redirect to login page instead of welcome page if allowRegistrations is false (#1185)
This commit is contained in:
@@ -31,11 +31,12 @@ const axiosInstance = axios.create({ baseURL: "./rest", withCredentials: true })
|
||||
axiosInstance.interceptors.response.use(
|
||||
response => response,
|
||||
error => {
|
||||
const { status, data } = error.response
|
||||
if (
|
||||
(error.response.status === 401 && error.response.data === "Credentials are required to access this resource.") ||
|
||||
(error.response.status === 403 && error.response.data === "You don't have the required role to access this resource.")
|
||||
(status === 401 && data?.message === "Credentials are required to access this resource.") ||
|
||||
(status === 403 && data?.message === "You don't have the required role to access this resource.")
|
||||
) {
|
||||
window.location.hash = "/welcome"
|
||||
window.location.hash = data?.allowRegistrations ? "/welcome" : "/login"
|
||||
}
|
||||
throw error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user