{ "version": 3, "sources": ["../../../../../../Modules/Membership/Account/Login/LoginPage.tsx"], "sourcesContent": ["/** @jsxImportSource jsx-dom */\nimport { LoginForm, LoginRequest } from \"@/ServerTypes/Membership\";\nimport { Texts } from \"@/ServerTypes/Texts\";\nimport { PropertyPanel } from \"@serenity-is/corelib\";\nimport { ErrorHandling, notifyError, parseQueryString, resolveUrl, serviceCall } from \"@serenity-is/corelib/q\";\nimport { PromptDialog } from \"@serenity-is/extensions\";\nimport { AccountPanelTitle } from \"../AccountPanelTitle\";\n\nexport default function pageInit(opt?: { activated: string, isPublicDemo: boolean }) {\n var loginPanel = new LoginPanel($('#LoginPanel'));\n\n if (opt?.isPublicDemo) {\n loginPanel.form.Username.element.val('admin').attr('placeholder', 'admin')\n loginPanel.form.Password.element.val('serenity').attr('placeholder', 'serenity');\n }\n\n if (opt?.activated) {\n loginPanel.form.Username.value = opt.activated;\n loginPanel.form.Password.element.focus();\n }\n}\n\nclass LoginPanel extends PropertyPanel {\n\n public readonly form = new LoginForm(this.idPrefix);\n\n protected getFormKey() { return LoginForm.formKey; }\n\n protected loginClick() {\n if (!this.validateForm())\n return;\n\n var request = this.getSaveEntity();\n\n serviceCall({\n url: resolveUrl('~/Account/Login'),\n request: request,\n onSuccess: () => {\n this.redirectToReturnUrl();\n },\n onError: response => {\n if (response?.Error?.Code === \"TwoFactorAuthenticationRequired\") {\n var args = response.Error.Arguments.split('|');\n this.handleTwoFactorAuthentication(request.Username, request.Password, args[1], args[0]);\n return;\n }\n\n if (response?.Error?.Code === \"RedirectUserTo\") {\n window.location.href = response.Error.Arguments;\n return;\n }\n\n if (response?.Error?.Message?.length) {\n notifyError(response.Error.Message);\n this.form.Password.element.focus();\n\n return;\n }\n\n ErrorHandling.showServiceError(response.Error);\n }\n });\n\n }\n\n protected redirectToReturnUrl() {\n var q = parseQueryString();\n var returnUrl = q['returnUrl'] || q['ReturnUrl'];\n if (returnUrl) {\n var hash = window.location.hash;\n if (hash != null && hash != '#')\n returnUrl += hash;\n window.location.href = returnUrl;\n }\n else {\n window.location.href = resolveUrl('~/');\n }\n }\n\n protected handleTwoFactorAuthentication(user: string, pass: string, twoFactorGuid: string, info: string) {\n var tries = 0;\n var remaining = 120;\n\n var dialog = null;\n\n var showDialog = () => {\n dialog = new PromptDialog({\n title: \"Two Factor Authentication\",\n editorOptions: {\n maxLength: 4,\n },\n editorType: \"Integer\",\n message: info,\n isHtml: true,\n required: true,\n validateValue: (x) => {\n if (x >= 1000 && x <= 9999) {\n tries++;\n\n serviceCall({\n url: resolveUrl('~/Account/Login'),\n request: {\n Username: user,\n Password: pass,\n TwoFactorGuid: twoFactorGuid,\n TwoFactorCode: x\n },\n onSuccess: () => {\n this.redirectToReturnUrl();\n return;\n },\n onError: z => {\n notifyError(z.Error.Message);\n\n if (tries > 2) {\n notifyError(\"Code entered is invalid! You can't try more than 3 times!\");\n dialog = null;\n return;\n }\n\n showDialog();\n }\n });\n\n return true;\n }\n\n notifyError(\"Please enter a valid code!\");\n return false;\n }\n });\n\n dialog.dialogOpen();\n dialog.element.on(\"dialogclose.me\", function() {\n if (dialog != null) {\n dialog.element.off(\"dialogclose.me\");\n dialog = null;\n }\n });\n };\n\n function updateCounter() {\n remaining -= 1;\n if (dialog != null) {\n dialog.element.find(\"span.counter\").text(remaining.toString());\n }\n\n if (remaining >= 0)\n setTimeout(updateCounter, 1000);\n else if (dialog != null)\n dialog.dialogClose();\n };\n\n showDialog();\n window.setTimeout(updateCounter, 1000);\n }\n\n protected renderContents() {\n const id = this.useIdPrefix();\n const myTexts = Texts.Forms.Membership.Login;\n this.element.empty().append(<>\n \n
\n
{myTexts.LoginToYourAccount}
\n
\n
\n \n
\n \n
\n
\n
\n );\n }\n}"], "mappings": "ydAGA,IAAAA,EAA8B,SAC9BC,EAAsF,SACtFC,EAA6B,SAGd,SAARC,EAA0BC,EAAoD,CACjF,IAAIC,EAAa,IAAIC,EAAW,EAAE,aAAa,CAAC,EAE5CF,GAAA,MAAAA,EAAK,eACL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,CACzC,CAEU,gBAAiB,CACvB,IAAMC,EAAK,KAAK,YAAY,EACtBC,EAAUC,EAAM,MAAM,WAAW,MACvC,KAAK,QAAQ,MAAM,EAAE,OAAOC,EAAAC,EAAA,CACxB,UAAAD,EAACE,EAAA,EAAkB,EACnBF,EAAC,OAAI,MAAM,cACP,UAAAA,EAAC,MAAG,MAAM,mBAAoB,SAAAF,EAAQ,mBAAmB,EACzDE,EAAC,QAAK,GAAIH,EAAG,KAAM,OAAO,GACtB,UAAAG,EAAC,OAAI,GAAIH,EAAG,aAAc,EAC1BG,EAAC,OAAI,MAAM,WACP,SAAAA,EAAC,KAAE,MAAM,iCAAiC,QAAM,cAAW,0BAA0B,EAChF,SAAAF,EAAQ,eACb,EACJ,EACAE,EAAC,OAAI,MAAM,WACP,SAAAA,EAAC,UAAO,GAAIH,EAAG,YAAa,KAAK,SAAS,MAAM,6BAC5C,QAASM,GAAK,CAAEA,EAAE,eAAe,EAAG,KAAK,WAAW,CAAG,EACtD,SAAAL,EAAQ,aACb,EACJ,GACJ,GACJ,GACJ,CAAG,CACP,CACJ,EA/JMxB,EAAAD,EAAA", "names": ["import_corelib", "import_q", "import_extensions", "pageInit", "opt", "loginPanel", "LoginPanel", "__name", "LoginForm", "request", "response", "_a", "_b", "_c", "_d", "args", "q", "returnUrl", "hash", "user", "pass", "twoFactorGuid", "info", "tries", "remaining", "dialog", "showDialog", "x", "z", "updateCounter", "id", "myTexts", "Texts", "jsx", "Fragment", "AccountPanelTitle", "e"] }