Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- onWindowBeforeUnload() {
- const appProperties = this.getModel('appProperties');
- if (appProperties.getProperty('/skipUnlockOnRedirect')) {
- appProperties.setProperty('/skipUnlockOnRedirect', false);
- return;
- }
- this.sendInfrcUnlockAsync(appProperties, this.getModel());
- }
- sendInfrcUnlockAsync(appProperties, oModel) {
- const _guid = appProperties.getProperty('/guid');
- if (!_guid) {
- return;
- }
- 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(`'${_guid}'`);
- xhr.open('POST', `${oModel.sServiceUrl}/InfrcUnlock?${sapClient}&Guid=${sGuid}`, true);
- xhr.setRequestHeader('x-csrf-token', oModel.getSecurityToken());
- xhr.send();
- }
RAW Paste Data