Question
UnitedHealth Group
US
Last activity: 7 Mar 2018 12:13 EST
Browser/Tab close for logoff event
We have a requirement to capture logoff on browser or tab close.
The client cannot enforce using the logoff feature.
We created TabCloseEventDetection(displayed below) which displayed a pop up box to the user when the tab or browser was closed. The User selects "OK" at which point they are logged off and the event recorded in the database.
The issue we are facing is upon auto logoff. When Pega auto logs out the Java script is also detected. The pop up box is displayed to process the logoff but because the user is not available to select, the logoff event is not completed.
Has anyone faced a similar requirement and what was the solution?
window.addEventListener("beforeunload", function (e) {
var confirmationMessage = "o/";
var p = (e || window.event).returnValue == confirmationMessage;
if(!p){
/ if(true){
//pega.u.d.replace('pyActivity=LogOff&pzPrimaryPageName=pyDisplayHarness', null);
alert("You will be Logged off");
var oSafeUrl = new SafeURL("@baseclass.LogOff");
var request = pega.u.d.asyncRequest('GET',oSafeUrl);
//window.open(oSafeURL.toURL(), null,[]);
}
else{
/ alert("Refresh");
}
});