I am working with HCP Portal SAPUI5 apps. I need to check the session before every data call is made to the backend so I can redirect the user back to the logon page.
In the HANA Cloud documentation, the below code is provided:
jQuery(document).ajaxComplete(function(e, jqXHR) {
if (jqXHR.getResponseHeader("com.sap.cloud.security.login")) {
alert("Session is expired, page shall be reloaded.");
jQuery.sap.delayedCall(0, this, function() {
location.reload(true);
});
}
});
But the above code only works for Ajax calls. I am not sure if the same works for odata as well. We want to redirect the user in every scenario after session expiry. Is there a direct method to achieve it both for data calls and Ajax calls?