This is an automated email from the ASF dual-hosted git repository. kishor pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/ranger.git
commit d0764e24030496f867b113aee95275d339d1dcaf Author: Mugdha Varadkar <mug...@apache.org> AuthorDate: Mon Aug 7 17:38:26 2023 +0530 RANGER-4341: Logout api call through idle timeout gets aborted Signed-off-by: Kishor Gollapalliwar <kishor.gollapalli...@gmail.com> --- .../src/main/webapp/react-webapp/src/utils/XAUtils.js | 10 +++++----- .../webapp/react-webapp/src/views/SideBar/SideBarBody.jsx | 14 ++++++++------ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/security-admin/src/main/webapp/react-webapp/src/utils/XAUtils.js b/security-admin/src/main/webapp/react-webapp/src/utils/XAUtils.js index 74b213a9d..80ce6acfe 100644 --- a/security-admin/src/main/webapp/react-webapp/src/utils/XAUtils.js +++ b/security-admin/src/main/webapp/react-webapp/src/utils/XAUtils.js @@ -1348,7 +1348,7 @@ export const updateTagActive = (isTagView) => { export const handleLogout = async (checkKnoxSSOVal, navigate) => { let logoutResp = {}; try { - logoutResp = fetchApi({ + logoutResp = await fetchApi({ url: "logout", baseURL: "", headers: { @@ -1356,7 +1356,7 @@ export const handleLogout = async (checkKnoxSSOVal, navigate) => { } }); if (checkKnoxSSOVal !== undefined || checkKnoxSSOVal !== null) { - if (checkKnoxSSOVal == false) { + if (checkKnoxSSOVal?.toString() == "false") { window.location.replace("/locallogin"); window.localStorage.clear(); } else { @@ -1372,7 +1372,7 @@ export const handleLogout = async (checkKnoxSSOVal, navigate) => { export const checkKnoxSSO = async (navigate) => { const userProfile = getUserProfile(); - let checkKnoxSSOresp; + let checkKnoxSSOresp = {}; try { checkKnoxSSOresp = await fetchApi({ url: "plugins/checksso", @@ -1382,12 +1382,12 @@ export const checkKnoxSSO = async (navigate) => { } }); if ( - checkKnoxSSOresp.data == "true" && + checkKnoxSSOresp?.data?.toString() == "true" && userProfile?.configProperties?.inactivityTimeout > 0 ) { window.location.replace("index.html?action=timeout"); } else { - handleLogout(checkKnoxSSOresp.data, navigate); + handleLogout(checkKnoxSSOresp?.data, navigate); } } catch (error) { if (checkKnoxSSOresp?.status == "419") { diff --git a/security-admin/src/main/webapp/react-webapp/src/views/SideBar/SideBarBody.jsx b/security-admin/src/main/webapp/react-webapp/src/views/SideBar/SideBarBody.jsx index 84ae52649..4d8494fc4 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/SideBar/SideBarBody.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/SideBar/SideBarBody.jsx @@ -226,7 +226,8 @@ export const SideBarBody = (props) => { const checkKnoxSSO = async (e) => { e.preventDefault(); - let checkKnoxSSOresp; + const userProfile = getUserProfile(); + let checkKnoxSSOresp = {}; try { checkKnoxSSOresp = await fetchApi({ url: "plugins/checksso", @@ -236,12 +237,12 @@ export const SideBarBody = (props) => { } }); if ( - checkKnoxSSOresp.data == "true" && - userProps?.configProperties?.inactivityTimeout > 0 + checkKnoxSSOresp?.data?.toString() == "true" && + userProfile?.configProperties?.inactivityTimeout > 0 ) { window.location.replace("index.html?action=timeout"); } else { - handleLogout(checkKnoxSSOresp.data); + handleLogout(checkKnoxSSOresp?.data); } } catch (error) { if (checkKnoxSSOresp?.status == "419") { @@ -253,8 +254,9 @@ export const SideBarBody = (props) => { }; const handleLogout = async (checkKnoxSSOVal) => { + let logoutResp = {}; try { - let logoutResp = await fetchApi({ + logoutResp = await fetchApi({ url: "logout", baseURL: "", headers: { @@ -262,7 +264,7 @@ export const SideBarBody = (props) => { } }); if (checkKnoxSSOVal !== undefined || checkKnoxSSOVal !== null) { - if (checkKnoxSSOVal == false) { + if (checkKnoxSSOVal?.toString() == "false") { window.location.replace("locallogin"); window.localStorage.clear(); setUserProfile(null);