Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- attachLeaveApplication() {
- $(window).unbind('beforeunload', this.leaveApplicationHandler);
- $(window).bind('beforeunload', {context: this}, this.leaveApplicationHandler);
- }
- leaveApplicationHandler(event) {
- if (event.data.context.getAppProperty('skipUnlockOnRedirect')) {
- event.data.context.setAppProperty('skipUnlockOnRedirect', false);
- return;
- }
- event.data.context.sendInfrcUnlockSynch(event);
- };
- /**
- *
- * @param oEvent
- */
- sendInfrcUnlockSynch(oEvent) {
- const xhr = new XMLHttpRequest(), sCookie = document.cookie;
- let sapClient = '';
- sCookie.split(';').forEach((i) => {
- const aParam = i.split('=');
- // we can have more '=' in cookie parameter string e.g sap-usercontext=sap-client=n
- if (aParam[0].trim() === 'sap-usercontext') {
- sapClient = i.substring(i.indexOf(aParam[1]));
- }
- });
- const sGuid = jQuery.sap.encodeURL(`'${this._guid}'`);
- xhr.open('POST', `${this._oModel.sServiceUrl}/InfrcUnlock?${sapClient}&Guid=${sGuid}`, true);
- xhr.setRequestHeader('x-csrf-token', this._oModel.getSecurityToken());
- xhr.send();
- }
RAW Paste Data