{"version":3,"file":"login-check.min.js","sources":["login-check.ts"],"sourcesContent":["namespace eXpress.core {\r\n\texport function WatchLogin() {\r\n\t\tconst emptyGuid = '00000000-0000-0000-0000-000000000000';\r\n\t\tlet timer = -1;\r\n\t\tlet startingAccId;\r\n\t\tlet accountType;\r\n\t\tlet dialog: eXpress.core.StyleguideViewPopup;\r\n\t\tlet openDialog = false;\r\n\r\n\t\tconst start = () => {\r\n\t\t\tif (timer < 0) {\r\n\t\t\t\tstartingAccId = eXpress.utils.getCookie(\"accid\");\r\n\t\t\t\taccountType = eXpress.utils.getCookie(\"acctype\");\r\n\t\t\t\t// @ts-ignore\r\n\t\t\t\ttimer = setInterval(() => { run(); }, 1500);\r\n\t\t\t}\r\n\t\t};\r\n\r\n\t\tconst run = () => {\r\n\t\t\tconst currentAccountId = eXpress.utils.getCookie(\"accid\");\r\n\t\t\tif (currentAccountId === startingAccId || openDialog) return; // return nothing to report\r\n\r\n\t\t\t// User logged out in another tab\r\n\t\t\tif (!currentAccountId || currentAccountId === emptyGuid) {\r\n\t\t\t\talert('Label.LoginManager.LogoutInDifferentTab', 'Label.LoginManager.LogoutInDifferentTab.PopupTitle');\r\n\t\t\t\tclearTimeout(timer);\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// User is logged in with a different account.\r\n\t\t\tif (accountType === 'full') {\r\n\t\t\t\t// We used to be a FULL, now a different account -> Impossible\r\n\t\t\t\talert('Label.LoginManager.DifferentAccount', 'Label.LoginManager.DifferentAccount.PopupTitle');\r\n\t\t\t\tclearTimeout(timer);\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// TEMP got merged into FULL -> OK\r\n\t\t\t// Different FULL -> NOK\r\n\t\t\t// We need a webservice call for this ...\r\n\t\t\topenDialog = true; // set this in case that the api call takese longer then the interval and it does it again\r\n\t\t\t$.ajax(\r\n\t\t\t\t{\r\n\t\t\t\t\turl: \"/api/v1/AccountService.svc/json/CheckAccountValidity\",\r\n\t\t\t\t\ttype: \"POST\",\r\n\t\t\t\t\tcontentType: 'application/json',\r\n\t\t\t\t\tdata: JSON.stringify({ oldAccountId: startingAccId, newAccountId: currentAccountId })\r\n\t\t\t\t}\r\n\t\t\t).then(res => {\r\n\t\t\t\topenDialog = false;\r\n\t\t\t\tif (!res) {\r\n\t\t\t\t\talert('Label.LoginManager.DifferentAccount', 'Label.LoginManager.DifferentAccount.PopupTitle');\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tstartingAccId = currentAccountId;\r\n\t\t\t});\r\n\t\t};\r\n\r\n\t\tconst alert = (key: string, title: string) => {\r\n\t\t\tif (openDialog) return;\r\n\t\t\topenDialog = true;\r\n\t\t\tconst dialogEl = html.querySelector<HTMLElement>(document, '.has-open-dialog', false);\r\n\t\t\tif (dialogEl && dialog)\r\n\t\t\t\tdialog.close(null);\r\n\r\n\t\t\teXpress.core.StyleguideViewPopup.createDialogAsync(\r\n\t\t\t\t{ view: 'DialogUX', dialogId: \"information\", forceRefresh: true },\r\n\t\t\t\t{ question: key, title, okmnemonic: 'Label.OkButtonText', cancelmnemonic: null, replacements: null })\r\n\t\t\t\t.then($popup => {\r\n\t\t\t\t\tdialog = new eXpress.core.StyleguideViewPopup($popup, { closeEvent: closeEventPopup, closeOnClickOutsidePopup: true });\r\n\t\t\t\t\tconst okbutton = html.querySelector<HTMLElement>($popup[0], '.technical-remove-confirmation-yes-button', false);\r\n\t\t\t\t\tif (okbutton) okbutton.addEventListener('click', () => closeEventPopup());\r\n\t\t\t\t\tdialog.openAsync();\r\n\t\t\t\t});\r\n\t\t};\r\n\r\n\t\tconst closeEventPopup = () => {\r\n\t\t\tlocation.reload();\r\n\t\t\topenDialog = false;\r\n\t\t};\r\n\r\n\t\tconst cancelEvent = () => {\r\n\t\t\topenDialog = true; // so that it does not open while we try to cancel\r\n\t\t\tclearTimeout(timer);\r\n\t\t};\r\n\r\n\t\tconst stop = () => {\r\n\t\t\tif (timer > 0)\r\n\t\t\t\tclearTimeout(timer);\r\n\t\t};\r\n\r\n\t\treturn {\r\n\t\t\tstart,\r\n\t\t\tcancelEvent,\r\n\t\t\tstop\r\n\t\t};\r\n\t}\r\n}\r\n"],"names":["eXpress","core","WatchLogin","startingAccId","accountType","dialog","timer","openDialog","run","currentAccountId","utils","getCookie","alert","clearTimeout","$","ajax","url","type","contentType","data","JSON","stringify","oldAccountId","newAccountId","then","res","key","title","html","querySelector","document","close","StyleguideViewPopup","createDialogAsync","view","dialogId","forceRefresh","question","okmnemonic","cancelmnemonic","replacements","$popup","closeEvent","closeEventPopup","closeOnClickOutsidePopup","okbutton","addEventListener","openAsync","location","reload","start","setInterval","cancelEvent","stop"],"mappings":"AAAA,IAAUA,SAAV,SAAUA,UAAQA,QAAIC,OAAJD,aAkGjB,CAAA,IAjGgBE,WAAhB,SAAgBA,aACf,IAEIC,cACAC,YACAC,OAHAC,OAAS,EAITC,YAAa,EAWXC,IAAM,WACX,IAAMC,iBAAmBT,QAAQU,MAAMC,UAAU,SACjD,GAAIF,mBAAqBN,gBAAiBI,WAA1C,CAGA,IAAKE,kBArBY,yCAqBQA,iBAGxB,OAFAG,MAAM,0CAA2C,2DACjDC,aAAaP,OAKd,GAAoB,SAAhBF,YAIH,OAFAQ,MAAM,sCAAuC,uDAC7CC,aAAaP,OAOdC,YAAa,EACbO,EAAEC,KACD,CACCC,IAAK,uDACLC,KAAM,OACNC,YAAa,mBACbC,KAAMC,KAAKC,UAAU,CAAEC,aAAcnB,cAAeoB,aAAcd,qBAElEe,MAAK,SAAAC,KACNlB,YAAa,EACRkB,IAKLtB,cAAgBM,iBAJfG,MAAM,sCAAuC,iDAK/C,GApC6D,CAqC9D,EAEMA,MAAQ,SAACc,IAAaC,OACvBpB,aACJA,YAAa,EACIP,QAAA4B,KAAKC,cAA2BC,SAAU,oBAAoB,IAC/DzB,QACfA,OAAO0B,MAAM,MAEd/B,QAAQC,KAAK+B,oBAAoBC,kBAChC,CAAEC,KAAM,WAAYC,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