From 05dc2a6d74456bc384b9f9600ba6f23db8ecbbe5 Mon Sep 17 00:00:00 2001 From: rktamil Date: Sun, 1 Sep 2024 00:41:48 +0000 Subject: [PATCH] Reject promise in checkError with logoutUser: false and without redirectTo causes an error #10172 --- .../ra-core/src/auth/useLogoutIfAccessDenied.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/ra-core/src/auth/useLogoutIfAccessDenied.ts b/packages/ra-core/src/auth/useLogoutIfAccessDenied.ts index 6bef2d3b81c..d886c215632 100644 --- a/packages/ra-core/src/auth/useLogoutIfAccessDenied.ts +++ b/packages/ra-core/src/auth/useLogoutIfAccessDenied.ts @@ -103,12 +103,17 @@ const useLogoutIfAccessDenied = (): LogoutIfAccessDenied => { if (logoutUser) { logout({}, redirectTo); } else { - if (redirectTo.startsWith('http')) { - // absolute link (e.g. https://my.oidc.server/login) - window.location.href = redirectTo; + if (redirectTo != null) { + if (redirectTo.startsWith('http')) { + // absolute link (e.g. https://my.oidc.server/login) + window.location.href = redirectTo; + } else { + // internal location + navigate(redirectTo); + } } else { - // internal location - navigate(redirectTo); + // If there is not redirect return false saying loguout is not successful + return false; } }