redirect to login page instead of welcome page if allowRegistrations is false (#1185)

This commit is contained in:
Athou
2024-01-11 16:21:54 +01:00
parent 9e4e629a1a
commit 8297edaf71
5 changed files with 26 additions and 15 deletions

View File

@@ -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
}