2 lines
51 KiB
JavaScript
2 lines
51 KiB
JavaScript
"use strict";(self.webpackChunkf7cloud_mail=self.webpackChunkf7cloud_mail||[]).push([[772],{38281:(t,n,a)=>{a.d(n,{A:()=>l});var e=a(71354),i=a.n(e),o=a(76314),s=a.n(o)()(i());s.push([t.id,"\nh4[data-v-89aa13e4] {\n\ttext-align: start;\n}\n.flex-row[data-v-89aa13e4] {\n\tdisplay: flex;\n}\ninput.primary[data-v-89aa13e4] {\n\tcolor: var(--color-main-background);\n}\ninput[type='radio'][data-v-89aa13e4] {\n\tdisplay: none;\n}\ninput[type='radio'][disabled] + label[data-v-89aa13e4] {\n\tcursor: default;\n\topacity: 0.5;\n}\n.account-form__label--required[data-v-89aa13e4]:after {\n\tcontent:\" *\";\n}\n.account-form__heading--required[data-v-89aa13e4]:after {\n\tcontent:\" *\";\n}\n.account-form__submit-buttons[data-v-89aa13e4] {\n\tdisplay: flex;\n\tjustify-content: center;\n\tmargin-top: var(--default-grid-baseline);\n}\n.account-form__submit-button[data-v-89aa13e4] {\n\tdisplay: flex;\n\talign-items: center;\n}\n.account-form--feedback[data-v-89aa13e4] {\n\tcolor: var(--color-text-maxcontrast);\n\tmargin-top: var(--default-grid-baseline);\n\ttext-align: center;\n}\n.account-form--error[data-v-89aa13e4] {\n\ttext-align: start;\n\tfont-size: 14px;\n}\n#account-form[data-v-89aa13e4] {\n\tz-index: 1001;\n\twidth: 300px;\n\ttop: 15%;\n\tpadding-bottom: calc(var(--default-grid-baseline) * 12);\n\tmargin: 0 auto;\n\tpadding-top: calc(var(--default-grid-baseline) * 7);\n}\n#account-form input[data-v-89aa13e4] {\n\twidth: 100%;\n\tbox-sizing: border-box;\n}\n","",{version:3,sources:["webpack://./src/components/AccountForm.vue"],names:[],mappings:";AAkvBA;CACA,iBAAA;AACA;AAEA;CACA,aAAA;AACA;AAEA;CACA,mCAAA;AACA;AAEA;CACA,aAAA;AACA;AAEA;CACA,eAAA;CACA,YAAA;AACA;AAEA;CACA,YAAA;AACA;AAEA;CACA,YAAA;AACA;AAEA;CACA,aAAA;CACA,uBAAA;CACA,wCAAA;AACA;AAEA;CACA,aAAA;CACA,mBAAA;AACA;AAEA;CACA,oCAAA;CACA,wCAAA;CACA,kBAAA;AACA;AAEA;CACA,iBAAA;CACA,eAAA;AACA;AAEA;CACA,aAAA;CACA,YAAA;CACA,QAAA;CACA,uDAAA;CACA,cAAA;CACA,mDAAA;AACA;AAEA;CACA,WAAA;CACA,sBAAA;AACA",sourcesContent:["\x3c!--\n - SPDX-FileCopyrightText: 2018 F7cloud GmbH and F7cloud contributors\n - SPDX-License-Identifier: AGPL-3.0-or-later\n--\x3e\n<template>\n\t<form id=\"account-form\" @submit.prevent=\"onSubmit\">\n\t\t<Tabs\n\t\t\t:options=\"{ useUrlFragment: false, defaultTabHash: settingsPage ? 'manual' : 'auto' }\"\n\t\t\tcache-lifetime=\"0\"\n\t\t\t@changed=\"onModeChanged\">\n\t\t\t<Tab id=\"auto\" key=\"auto\" :name=\"t('mail', 'Auto')\">\n\t\t\t\t<NcInputField\n\t\t\t\t\tid=\"auto-name\"\n\t\t\t\t\t:value.sync=\"accountName\"\n\t\t\t\t\t:label=\"t('mail', 'Name')\"\n\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t:placeholder=\"t('mail', 'Name')\"\n\t\t\t\t\t:disabled=\"loading\"\n\t\t\t\t\tautofocus />\n\t\t\t\t<NcInputField\n\t\t\t\t\tid=\"auto-address\"\n\t\t\t\t\t:value.sync=\"emailAddress\"\n\t\t\t\t\t:label=\"t('mail', 'Mail address')\"\n\t\t\t\t\t:disabled=\"loading\"\n\t\t\t\t\t:placeholder=\"t('mail', 'name@example.org')\"\n\t\t\t\t\trequired\n\t\t\t\t\ttype=\"email\"\n\t\t\t\t\t@change=\"clearFeedback\" />\n\t\t\t\t<p v-if=\"!isValidEmail(emailAddress)\" class=\"account-form--error\">\n\t\t\t\t\t{{ t('mail', 'Please enter an email of the format name@example.com') }}\n\t\t\t\t</p>\n\t\t\t\t<NcPasswordField\n\t\t\t\t\tid=\"auto-password\"\n\t\t\t\t\t:value.sync=\"autoConfig.password\"\n\t\t\t\t\t:disabled=\"loading\"\n\t\t\t\t\ttype=\"password\"\n\t\t\t\t\t:label=\"t('mail', 'Password')\"\n\t\t\t\t\t:required=\"!hasPasswordAlternatives\"\n\t\t\t\t\t@change=\"clearFeedback\" />\n\t\t\t</Tab>\n\t\t\t<Tab id=\"manual\" key=\"manual\" :name=\"t('mail', 'Manual')\">\n\t\t\t\t<NcInputField\n\t\t\t\t\tid=\"man-name\"\n\t\t\t\t\t:value.sync=\"accountName\"\n\t\t\t\t\t:label=\"t('mail', 'Name')\"\n\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t:placeholder=\"t('mail', 'Name')\"\n\t\t\t\t\t:disabled=\"loading\" />\n\t\t\t\t<NcInputField\n\t\t\t\t\tid=\"man-address\"\n\t\t\t\t\t:value.sync=\"emailAddress\"\n\t\t\t\t\t:label=\"t('mail', 'Mail address')\"\n\t\t\t\t\ttype=\"email\"\n\t\t\t\t\t:placeholder=\"t('mail', 'name@example.org')\"\n\t\t\t\t\t:disabled=\"loading\"\n\t\t\t\t\trequired\n\t\t\t\t\t@change=\"clearFeedback\" />\n\t\t\t\t<p v-if=\"!isValidEmail(emailAddress)\" class=\"account-form--error\">\n\t\t\t\t\t{{ t('mail', 'Please enter an email of the format name@example.com') }}\n\t\t\t\t</p>\n\n\t\t\t\t<h3>{{ t('mail', 'IMAP Settings') }}</h3>\n\t\t\t\t<NcInputField\n\t\t\t\t\tid=\"man-imap-host\"\n\t\t\t\t\t:value.sync=\"manualConfig.imapHost\"\n\t\t\t\t\t:label=\"t('mail', 'IMAP Host')\"\n\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t:placeholder=\"t('mail', 'IMAP Host')\"\n\t\t\t\t\t:disabled=\"loading\"\n\t\t\t\t\trequired\n\t\t\t\t\t@change=\"clearFeedback\" />\n\t\t\t\t<h4 class=\"account-form__heading--required\">\n\t\t\t\t\t{{ t('mail', 'IMAP Security') }}\n\t\t\t\t</h4>\n\t\t\t\t<div class=\"flex-row\">\n\t\t\t\t\t<NcCheckboxRadioSwitch\n\t\t\t\t\t\tid=\"man-imap-sec-none\"\n\t\t\t\t\t\t:button-variant=\"true\"\n\t\t\t\t\t\t:checked=\"manualConfig.imapSslMode\"\n\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\tname=\"man-imap-sec\"\n\t\t\t\t\t\t:disabled=\"loading\"\n\t\t\t\t\t\tvalue=\"none\"\n\t\t\t\t\t\tbutton-variant-grouped=\"horizontal\"\n\t\t\t\t\t\t@update:checked=\"onImapSslModeChange\">\n\t\t\t\t\t\t{{ t('mail', 'None') }}\n\t\t\t\t\t</NcCheckboxRadioSwitch>\n\t\t\t\t\t<NcCheckboxRadioSwitch\n\t\t\t\t\t\tid=\"man-imap-sec-ssl\"\n\t\t\t\t\t\t:button-variant=\"true\"\n\t\t\t\t\t\t:checked=\"manualConfig.imapSslMode\"\n\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\tname=\"man-imap-sec\"\n\t\t\t\t\t\t:disabled=\"loading\"\n\t\t\t\t\t\tvalue=\"ssl\"\n\t\t\t\t\t\tbutton-variant-grouped=\"horizontal\"\n\t\t\t\t\t\t@update:checked=\"onImapSslModeChange\">\n\t\t\t\t\t\t{{ t('mail', 'SSL/TLS') }}\n\t\t\t\t\t</NcCheckboxRadioSwitch>\n\t\t\t\t\t<NcCheckboxRadioSwitch\n\t\t\t\t\t\tid=\"man-imap-sec-tls\"\n\t\t\t\t\t\t:button-variant=\"true\"\n\t\t\t\t\t\t:checked=\"manualConfig.imapSslMode\"\n\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\tname=\"man-imap-sec\"\n\t\t\t\t\t\t:disabled=\"loading\"\n\t\t\t\t\t\tvalue=\"tls\"\n\t\t\t\t\t\tbutton-variant-grouped=\"horizontal\"\n\t\t\t\t\t\t@update:checked=\"onImapSslModeChange\">\n\t\t\t\t\t\t{{ t('mail', 'STARTTLS') }}\n\t\t\t\t\t</NcCheckboxRadioSwitch>\n\t\t\t\t</div>\n\t\t\t\t<NcInputField\n\t\t\t\t\tid=\"man-imap-port\"\n\t\t\t\t\t:value.sync=\"manualConfig.imapPort\"\n\t\t\t\t\t:label=\"t('mail', 'IMAP Port')\"\n\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t:placeholder=\"t('mail', 'IMAP Port')\"\n\t\t\t\t\t:disabled=\"loading\"\n\t\t\t\t\trequired\n\t\t\t\t\t@change=\"clearFeedback\" />\n\t\t\t\t<NcInputField\n\t\t\t\t\tid=\"man-imap-user\"\n\t\t\t\t\t:value.sync=\"manualConfig.imapUser\"\n\t\t\t\t\t:label=\"t('mail', 'IMAP User')\"\n\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t:placeholder=\"t('mail', 'IMAP User')\"\n\t\t\t\t\t:disabled=\"loading\"\n\t\t\t\t\trequired\n\t\t\t\t\t@change=\"clearFeedback\" />\n\t\t\t\t<NcPasswordField\n\t\t\t\t\tv-if=\"!useOauth\"\n\t\t\t\t\tid=\"man-imap-password\"\n\t\t\t\t\ttype=\"password\"\n\t\t\t\t\t:value.sync=\"manualConfig.imapPassword\"\n\t\t\t\t\t:label=\"t('mail', 'IMAP Password')\"\n\t\t\t\t\t:disabled=\"loading\"\n\t\t\t\t\trequired\n\t\t\t\t\t@change=\"clearFeedback\" />\n\n\t\t\t\t<h3>{{ t('mail', 'SMTP Settings') }}</h3>\n\t\t\t\t<NcInputField\n\t\t\t\t\tid=\"man-smtp-host\"\n\t\t\t\t\tref=\"smtpHost\"\n\t\t\t\t\t:value.sync=\"manualConfig.smtpHost\"\n\t\t\t\t\t:label=\"t('mail', 'SMTP Host')\"\n\t\t\t\t\ttype=\"text\"\n\t\t\t\t\tname=\"smtp-host\"\n\t\t\t\t\t:placeholder=\"t('mail', 'SMTP Host')\"\n\t\t\t\t\t:disabled=\"loading\"\n\t\t\t\t\trequired\n\t\t\t\t\t@change=\"clearFeedback\" />\n\t\t\t\t<h4 class=\"account-form__heading--required\">\n\t\t\t\t\t{{ t('mail', 'SMTP Security') }}\n\t\t\t\t</h4>\n\t\t\t\t<div class=\"flex-row\">\n\t\t\t\t\t<NcCheckboxRadioSwitch\n\t\t\t\t\t\tid=\"man-imap-sec-none\"\n\t\t\t\t\t\t:button-variant=\"true\"\n\t\t\t\t\t\t:checked=\"manualConfig.smtpSslMode\"\n\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\tname=\"man-smtp-sec\"\n\t\t\t\t\t\t:disabled=\"loading\"\n\t\t\t\t\t\tvalue=\"none\"\n\t\t\t\t\t\tbutton-variant-grouped=\"horizontal\"\n\t\t\t\t\t\t@update:checked=\"onSmtpSslModeChange\">\n\t\t\t\t\t\t{{ t('mail', 'None') }}\n\t\t\t\t\t</NcCheckboxRadioSwitch>\n\t\t\t\t\t<NcCheckboxRadioSwitch\n\t\t\t\t\t\tid=\"man-imap-sec-ssl\"\n\t\t\t\t\t\t:button-variant=\"true\"\n\t\t\t\t\t\t:checked=\"manualConfig.smtpSslMode\"\n\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\tname=\"man-smtp-sec\"\n\t\t\t\t\t\t:disabled=\"loading\"\n\t\t\t\t\t\tvalue=\"ssl\"\n\t\t\t\t\t\tbutton-variant-grouped=\"horizontal\"\n\t\t\t\t\t\t@update:checked=\"onSmtpSslModeChange\">\n\t\t\t\t\t\t{{ t('mail', 'SSL/TLS') }}\n\t\t\t\t\t</NcCheckboxRadioSwitch>\n\t\t\t\t\t<NcCheckboxRadioSwitch\n\t\t\t\t\t\tid=\"man-imap-sec-tls\"\n\t\t\t\t\t\t:button-variant=\"true\"\n\t\t\t\t\t\t:checked=\"manualConfig.smtpSslMode\"\n\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\tname=\"man-smtp-sec\"\n\t\t\t\t\t\t:disabled=\"loading\"\n\t\t\t\t\t\tvalue=\"tls\"\n\t\t\t\t\t\tbutton-variant-grouped=\"horizontal\"\n\t\t\t\t\t\t@update:checked=\"onSmtpSslModeChange\">\n\t\t\t\t\t\t{{ t('mail', 'STARTTLS') }}\n\t\t\t\t\t</NcCheckboxRadioSwitch>\n\t\t\t\t</div>\n\t\t\t\t<NcInputField\n\t\t\t\t\tid=\"man-smtp-port\"\n\t\t\t\t\t:label=\"t('mail', 'SMTP Port')\"\n\t\t\t\t\t:value.sync=\"manualConfig.smtpPort\"\n\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t:placeholder=\"t('mail', 'SMTP Port')\"\n\t\t\t\t\t:disabled=\"loading\"\n\t\t\t\t\trequired\n\t\t\t\t\t@change=\"clearFeedback\" />\n\t\t\t\t<NcInputField\n\t\t\t\t\tid=\"man-smtp-user\"\n\t\t\t\t\t:value.sync=\"manualConfig.smtpUser\"\n\t\t\t\t\t:label=\"t('mail', 'SMTP User')\"\n\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t:placeholder=\"t('mail', 'SMTP User')\"\n\t\t\t\t\t:disabled=\"loading\"\n\t\t\t\t\trequired\n\t\t\t\t\t@change=\"clearFeedback\" />\n\t\t\t\t<NcPasswordField\n\t\t\t\t\tv-if=\"!useOauth\"\n\t\t\t\t\tid=\"man-smtp-password\"\n\t\t\t\t\t:label=\"t('mail', 'SMTP Password')\"\n\t\t\t\t\ttype=\"password\"\n\t\t\t\t\t:value.sync=\"manualConfig.smtpPassword\"\n\t\t\t\t\t:disabled=\"loading\"\n\t\t\t\t\trequired\n\t\t\t\t\t@change=\"clearFeedback\" />\n\t\t\t</Tab>\n\t\t</Tabs>\n\t\t<div v-if=\"isGoogleAccount && !googleOauthUrl\" class=\"account-form__google-sso\">\n\t\t\t{{ t('mail', 'For the Google account to work with this app you need to enable two-factor authentication for Google and generate an app password.') }}\n\t\t</div>\n\t\t<div class=\"account-form__submit-buttons\">\n\t\t\t<ButtonVue\n\t\t\t\tv-if=\"mode === 'auto'\"\n\t\t\t\t:aria-label=\"submitButtonText\"\n\t\t\t\tclass=\"account-form__submit-button\"\n\t\t\t\ttype=\"primary\"\n\t\t\t\tnative-type=\"submit\"\n\t\t\t\t:disabled=\"isDisabledAuto || loading\"\n\t\t\t\t@click.prevent=\"onSubmit\">\n\t\t\t\t<template #icon>\n\t\t\t\t\t<IconLoading v-if=\"loading\" :size=\"20\" />\n\t\t\t\t\t<IconCheck v-else :size=\"20\" />\n\t\t\t\t</template>\n\t\t\t\t{{ submitButtonText }}\n\t\t\t</ButtonVue>\n\t\t\t<ButtonVue\n\t\t\t\tv-else-if=\"mode === 'manual'\"\n\t\t\t\t:aria-label=\"submitButtonText\"\n\t\t\t\tclass=\"account-form__submit-button\"\n\t\t\t\ttype=\"primary\"\n\t\t\t\tnative-type=\"submit\"\n\t\t\t\t:disabled=\"isDisabledManual || loading\"\n\t\t\t\t@click.prevent=\"onSubmit\">\n\t\t\t\t<template #icon>\n\t\t\t\t\t<IconLoading v-if=\"loading\" :size=\"20\" />\n\t\t\t\t\t<IconCheck v-else :size=\"20\" />\n\t\t\t\t</template>\n\t\t\t\t{{ submitButtonText }}\n\t\t\t</ButtonVue>\n\t\t</div>\n\t\t<div v-if=\"feedback\" class=\"account-form--feedback\">\n\t\t\t{{ feedback }}\n\t\t</div>\n\t</form>\n</template>\n\n<script>\nimport { translate as t } from '@f7cloud/l10n'\nimport { NcButton as ButtonVue, NcLoadingIcon as IconLoading, NcCheckboxRadioSwitch, NcInputField, NcPasswordField } from '@f7cloud/vue'\nimport { mapState, mapStores } from 'pinia'\nimport { Tab, Tabs } from 'vue-tabs-component'\nimport IconCheck from 'vue-material-design-icons/Check.vue'\nimport { CONSENT_ABORTED, getUserConsent } from '../integration/oauth.js'\nimport logger from '../logger.js'\nimport {\n\tqueryIspdb,\n\tqueryMx,\n\ttestConnectivity,\n} from '../service/AutoConfigService.js'\nimport useMainStore from '../store/mainStore.js'\n\nexport default {\n\tname: 'AccountForm',\n\tcomponents: {\n\t\tNcPasswordField,\n\t\tNcInputField,\n\t\tNcCheckboxRadioSwitch,\n\t\tTab,\n\t\tTabs,\n\t\tButtonVue,\n\t\tIconLoading,\n\t\tIconCheck,\n\t},\n\n\tprops: {\n\t\tdisplayName: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\temail: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\taccount: {\n\t\t\ttype: Object,\n\t\t\trequired: false,\n\t\t\tdefault: () => undefined,\n\t\t},\n\t},\n\n\tdata() {\n\t\tconst fromAccountOr = (prop, def) => {\n\t\t\tif (this.account !== undefined) {\n\t\t\t\treturn this.account[prop]\n\t\t\t} else {\n\t\t\t\treturn def\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tloading: false,\n\t\t\tloadingMessage: undefined,\n\t\t\tmode: 'auto',\n\t\t\taccountName: this.displayName,\n\t\t\temailAddress: this.email,\n\t\t\tautoConfig: {\n\t\t\t\tpassword: '',\n\t\t\t},\n\n\t\t\tmanualConfig: {\n\t\t\t\timapHost: fromAccountOr('imapHost', ''),\n\t\t\t\timapPort: fromAccountOr('imapPort', 993),\n\t\t\t\timapSslMode: fromAccountOr('imapSslMode', 'ssl'),\n\t\t\t\timapUser: fromAccountOr('imapUser', ''),\n\t\t\t\timapPassword: '',\n\t\t\t\tsmtpHost: fromAccountOr('smtpHost', ''),\n\t\t\t\tsmtpPort: fromAccountOr('smtpPort', 587),\n\t\t\t\tsmtpSslMode: fromAccountOr('smtpSslMode', 'tls'),\n\t\t\t\tsmtpUser: fromAccountOr('smtpUser', ''),\n\t\t\t\tsmtpPassword: '',\n\t\t\t},\n\n\t\t\tfeedback: null,\n\t\t\tpassword: '',\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t...mapStores(useMainStore),\n\t\t...mapState(useMainStore, [\n\t\t\t'googleOauthUrl',\n\t\t\t'microsoftOauthUrl',\n\t\t]),\n\n\t\tsettingsPage() {\n\t\t\treturn this.account !== undefined\n\t\t},\n\n\t\tisDisabledAuto() {\n\t\t\tif (this.loading) {\n\t\t\t\treturn true\n\t\t\t}\n\n\t\t\tif (this.mode !== 'auto') {\n\t\t\t\treturn this.loading\n\t\t\t}\n\n\t\t\treturn !this.emailAddress || !this.isValidEmail(this.emailAddress)\n\t\t\t\t|| (!this.googleOauthUrl && !this.autoConfig.password)\n\t\t\t\t|| (!this.microsoftOauthUrl && !this.autoConfig.password)\n\t\t},\n\n\t\tisDisabledManual() {\n\t\t\tif (this.loading) {\n\t\t\t\treturn true\n\t\t\t}\n\n\t\t\tif (this.mode !== 'manual') {\n\t\t\t\treturn this.loading\n\t\t\t}\n\n\t\t\treturn !this.emailAddress || !this.isValidEmail(this.emailAddress)\n\t\t\t\t|| !this.manualConfig.imapHost || !this.manualConfig.imapPort\n\t\t\t\t|| !this.manualConfig.imapUser || (!this.useOauth && !this.manualConfig.imapPassword)\n\t\t\t\t|| !this.manualConfig.smtpHost || !this.manualConfig.smtpPort\n\t\t\t\t|| !this.manualConfig.smtpUser || (!this.useOauth && !this.manualConfig.smtpPassword)\n\t\t},\n\n\t\tisGoogleAccount() {\n\t\t\treturn this.manualConfig.imapHost === 'imap.gmail.com'\n\t\t\t\t|| this.manualConfig.smtpHost === 'smtp.gmail.com'\n\t\t},\n\n\t\tisMicrosoftAccount() {\n\t\t\treturn this.manualConfig.imapHost === 'outlook.office365.com'\n\t\t\t\t|| this.manualConfig.smtpHost === 'outlook.office365.com'\n\t\t},\n\n\t\thasPasswordAlternatives() {\n\t\t\treturn !!this.googleOauthUrl\n\t\t\t\t|| !!this.microsoftOauthUrl\n\t\t},\n\n\t\tuseOauth() {\n\t\t\treturn (this.isGoogleAccount && this.googleOauthUrl)\n\t\t\t\t|| (this.isMicrosoftAccount && this.microsoftOauthUrl)\n\t\t},\n\n\t\tsubmitButtonText() {\n\t\t\tif (this.loading) {\n\t\t\t\treturn this.loadingMessage ?? t('mail', 'Connecting')\n\t\t\t}\n\t\t\tif (this.mode === 'manual' && this.useOauth) {\n\t\t\t\tif (this.isGoogleAccount) {\n\t\t\t\t\treturn this.account ? t('mail', 'Reconnect Google account') : t('mail', 'Sign in with Google')\n\t\t\t\t} else {\n\t\t\t\t\treturn this.account ? t('mail', 'Reconnect Microsoft account') : t('mail', 'Sign in with Microsoft')\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn this.account ? t('mail', 'Save') : t('mail', 'Connect')\n\t\t},\n\t},\n\n\tmethods: {\n\t\tonModeChanged(e) {\n\t\t\tthis.mode = e.tab.id\n\n\t\t\tif (this.mode === 'manual') {\n\t\t\t\t// IMAP\n\t\t\t\tif (this.manualConfig.imapUser === '') {\n\t\t\t\t\tthis.manualConfig.imapUser = this.emailAddress\n\t\t\t\t}\n\t\t\t\tif (this.manualConfig.imapPassword === '') {\n\t\t\t\t\tthis.manualConfig.imapPassword = this.autoConfig.password\n\t\t\t\t}\n\n\t\t\t\t// SMTP\n\t\t\t\tif (this.manualConfig.smtpUser === '') {\n\t\t\t\t\tthis.manualConfig.smtpUser = this.emailAddress\n\t\t\t\t}\n\t\t\t\tif (this.manualConfig.smtpPassword === '') {\n\t\t\t\t\tthis.manualConfig.smtpPassword = this.autoConfig.password\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\tonImapSslModeChange(value) {\n\t\t\tthis.clearFeedback()\n\t\t\tthis.manualConfig.imapSslMode = value\n\t\t\tswitch (this.manualConfig.imapSslMode) {\n\t\t\t\tcase 'none':\n\t\t\t\tcase 'tls':\n\t\t\t\t\tthis.manualConfig.imapPort = 143\n\t\t\t\t\tbreak\n\t\t\t\tcase 'ssl':\n\t\t\t\t\tthis.manualConfig.imapPort = 993\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t},\n\n\t\tonSmtpSslModeChange(value) {\n\t\t\tthis.clearFeedback()\n\t\t\tthis.manualConfig.smtpSslMode = value\n\t\t\tswitch (this.manualConfig.smtpSslMode) {\n\t\t\t\tcase 'none':\n\t\t\t\tcase 'tls':\n\t\t\t\t\tthis.manualConfig.smtpPort = 587\n\t\t\t\t\tbreak\n\t\t\t\tcase 'ssl':\n\t\t\t\t\tthis.manualConfig.smtpPort = 465\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t},\n\n\t\tclearFeedback() {\n\t\t\tthis.feedback = null\n\t\t},\n\n\t\tapplyAutoConfig(config) {\n\t\t\tif (!config) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif (config?.imapConfig) {\n\t\t\t\tthis.manualConfig.imapUser = config.imapConfig.username\n\t\t\t\tthis.manualConfig.imapHost = config.imapConfig.host\n\t\t\t\tthis.manualConfig.imapPort = config.imapConfig.port\n\t\t\t\tthis.manualConfig.imapSslMode = config.imapConfig.security\n\t\t\t\tthis.manualConfig.imapPassword = this.autoConfig.password\n\t\t\t}\n\t\t\tif (config?.smtpConfig) {\n\t\t\t\tthis.manualConfig.smtpUser = config.smtpConfig.username\n\t\t\t\tthis.manualConfig.smtpHost = config.smtpConfig.host\n\t\t\t\tthis.manualConfig.smtpPort = config.smtpConfig.port\n\t\t\t\tthis.manualConfig.smtpSslMode = config.smtpConfig.security\n\t\t\t\tthis.manualConfig.smtpPassword = this.autoConfig.password\n\t\t\t}\n\t\t\treturn true\n\t\t},\n\n\t\tasync detectConfig() {\n\t\t\tthis.loadingMessage = t('mail', 'Looking up configuration')\n\t\t\tconst config = await queryIspdb(this.emailAddress.split('@').pop(), this.emailAddress)\n\t\t\tlogger.debug('fetched auto config', { config })\n\t\t\t// Apply settings to manual mode before submitting so the user\n\t\t\t// can make modifications if the config fails\n\t\t\tif (this.applyAutoConfig(config)) {\n\t\t\t\tlogger.debug('ISP DB config applied')\n\t\t\t\treturn true\n\t\t\t} else {\n\t\t\t\tconst mxHosts = await queryMx(this.emailAddress)\n\t\t\t\tlogger.debug('MX hosts fetched', { mxHosts })\n\n\t\t\t\tif (mxHosts.length) {\n\t\t\t\t\t// Try the TLD of the MX\n\t\t\t\t\t// FIXME: breaks with eTLDs like .co.uk\n\t\t\t\t\tconst tldMx = mxHosts[0].split('.').splice(-2).join('.').toLowerCase()\n\t\t\t\t\tconst mxConfig = await queryIspdb(\n\t\t\t\t\t\ttldMx,\n\t\t\t\t\t\tthis.emailAddress,\n\t\t\t\t\t)\n\t\t\t\t\tlogger.debug('fetched MX auto config', { mxConfig })\n\t\t\t\t\tif (mxConfig && this.applyAutoConfig(mxConfig)) {\n\t\t\t\t\t\treturn true\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Test the highest priority MX for open IMAP/SMTP ports\n\t\t\t\tthis.loadingMessage = t('mail', 'Checking mail host connectivity')\n\t\t\t\tconst imapAndSmtpHosts = mxHosts.slice(0, 1).flatMap((host) => {\n\t\t\t\t\treturn [993, 143, 465, 587].map((port) => ({\n\t\t\t\t\t\thost,\n\t\t\t\t\t\tport,\n\t\t\t\t\t}))\n\t\t\t\t})\n\t\t\t\tconst results = await Promise.all(imapAndSmtpHosts.map(async ({ host, port }) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\thost,\n\t\t\t\t\t\tport,\n\t\t\t\t\t\tcanConnect: await testConnectivity(host, port),\n\t\t\t\t\t}\n\t\t\t\t}))\n\t\t\t\tconst firstImapHost = results.filter(({ canConnect, port }) => canConnect && port === 993)[0]\n\t\t\t\tconst firstSmtpHost = results.filter(({ canConnect, port }) => canConnect && [465, 587].includes(port))[0]\n\t\t\t\tlogger.debug('MX connectivity tested', { firstImapHost, firstSmtpHost })\n\t\t\t\tif (firstImapHost && firstSmtpHost) {\n\t\t\t\t\tthis.applyAutoConfig({\n\t\t\t\t\t\timapConfig: {\n\t\t\t\t\t\t\tusername: this.emailAddress, // Assumption\n\t\t\t\t\t\t\thost: firstImapHost.host,\n\t\t\t\t\t\t\tport: firstImapHost.port,\n\t\t\t\t\t\t\tsecurity: firstImapHost.port === 993 ? 'ssl' : 'tls',\n\t\t\t\t\t\t},\n\t\t\t\t\t\tsmtpConfig: {\n\t\t\t\t\t\t\tusername: this.emailAddress, // Assumption\n\t\t\t\t\t\t\thost: firstSmtpHost.host,\n\t\t\t\t\t\t\tport: firstSmtpHost.port,\n\t\t\t\t\t\t\tsecurity: firstSmtpHost.port === 465 ? 'ssl' : 'tls',\n\t\t\t\t\t\t},\n\t\t\t\t\t})\n\t\t\t\t\treturn true\n\t\t\t\t} else {\n\t\t\t\t\tthis.feedback = t('mail', 'Configuration discovery failed. Please use the manual settings')\n\t\t\t\t}\n\t\t\t\treturn false\n\t\t\t}\n\t\t},\n\n\t\tasync onSubmit(event) {\n\t\t\tlogger.debug('account form submitted', { event })\n\t\t\tif (this.isDisabledManual || this.isDisabledAuto) {\n\t\t\t\tlogger.warn('submit is disabled')\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.clearFeedback()\n\t\t\tthis.loading = true\n\t\t\ttry {\n\t\t\t\tif (this.mode === 'auto') {\n\t\t\t\t\tif (!await this.detectConfig()) {\n\t\t\t\t\t\tlogger.warn('Auto mode failed')\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!this.useOauth) {\n\t\t\t\t\tif (this.mode === 'auto' && this.autoConfig.password === '') {\n\t\t\t\t\t\tthis.feedback = t('mail', 'Password required')\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tif (this.mode === 'manual' && (this.manualConfig.imapPassword === '' || this.manualConfig.smtpPassword === '')) {\n\t\t\t\t\t\tthis.feedback = t('mail', 'Password required')\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.loadingMessage = t('mail', 'Testing authentication')\n\t\t\t\tconst data = {\n\t\t\t\t\t...this.manualConfig,\n\t\t\t\t\taccountName: this.accountName,\n\t\t\t\t\temailAddress: this.emailAddress,\n\t\t\t\t\timapHost: this.manualConfig.imapHost.trim(),\n\t\t\t\t\tsmtpHost: this.manualConfig.smtpHost.trim(),\n\t\t\t\t\tauthMethod: this.useOauth ? 'xoauth2' : 'password',\n\t\t\t\t}\n\t\t\t\tif (this.useOauth) {\n\t\t\t\t\tdelete data.imapPassword\n\t\t\t\t\tdelete data.smtpPassword\n\t\t\t\t}\n\t\t\t\tif (!this.account) {\n\t\t\t\t\tconst account = await this.mainStore.startAccountSetup(data)\n\t\t\t\t\tif (this.useOauth) {\n\t\t\t\t\t\tthis.loadingMessage = t('mail', 'Awaiting user consent')\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tif (this.isGoogleAccount) {\n\t\t\t\t\t\t\t\tthis.feedback = t('mail', 'Account created. Please follow the pop-up instructions to link your Google account')\n\t\t\t\t\t\t\t\tawait getUserConsent(this.googleOauthUrl\n\t\t\t\t\t\t\t\t\t.replace('_accountId_', account.id)\n\t\t\t\t\t\t\t\t\t.replace('_email_', encodeURIComponent(account.emailAddress)))\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthis.feedback = t('mail', 'Account created. Please follow the pop-up instructions to link your Microsoft account')\n\t\t\t\t\t\t\t\tawait getUserConsent(this.microsoftOauthUrl\n\t\t\t\t\t\t\t\t\t.replace('_accountId_', account.id)\n\t\t\t\t\t\t\t\t\t.replace('_email_', encodeURIComponent(account.emailAddress)))\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\t// Clean up the temporary account before we continue\n\t\t\t\t\t\t\tthis.mainStore.deleteAccount(account)\n\t\t\t\t\t\t\tlogger.info(`Temporary account ${account.id} deleted`)\n\t\t\t\t\t\t\tthrow e\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.clearFeedback()\n\t\t\t\t\t}\n\t\t\t\t\tthis.loadingMessage = t('mail', 'Loading account')\n\t\t\t\t\tawait this.mainStore.finishAccountSetup({ account })\n\t\t\t\t\tthis.$emit('account-created', account)\n\t\t\t\t} else {\n\t\t\t\t\tconst oldAccountData = this.account\n\t\t\t\t\tconst account = await this.mainStore.updateAccount({\n\t\t\t\t\t\t...data,\n\t\t\t\t\t\taccountId: this.account.id,\n\t\t\t\t\t})\n\t\t\t\t\tif (this.useOauth) {\n\t\t\t\t\t\tthis.loadingMessage = t('mail', 'Awaiting user consent')\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tif (this.isGoogleAccount) {\n\t\t\t\t\t\t\t\tthis.feedback = t('mail', 'Account updated. Please follow the pop-up instructions to reconnect your Google account')\n\t\t\t\t\t\t\t\tawait getUserConsent(this.googleOauthUrl\n\t\t\t\t\t\t\t\t\t.replace('_accountId_', account.id)\n\t\t\t\t\t\t\t\t\t.replace('_email_', encodeURIComponent(account.emailAddress)))\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthis.feedback = t('mail', 'Account updated. Please follow the pop-up instructions to reconnect your Microsoft account')\n\t\t\t\t\t\t\t\tawait getUserConsent(this.microsoftOauthUrl\n\t\t\t\t\t\t\t\t\t.replace('_accountId_', account.id)\n\t\t\t\t\t\t\t\t\t.replace('_email_', encodeURIComponent(account.emailAddress)))\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\t// Undo changes\n\t\t\t\t\t\t\tawait this.mainStore.updateAccount({\n\t\t\t\t\t\t\t\t...oldAccountData,\n\t\t\t\t\t\t\t\taccountId: oldAccountData.id,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\tlogger.info(`Account ${account.id} update undone`)\n\t\t\t\t\t\t\tthrow e\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.clearFeedback()\n\t\t\t\t\t}\n\t\t\t\t\tthis.feedback = t('mail', 'Account updated')\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tlogger.error('could not save account details', { error })\n\n\t\t\t\tif (error.data?.error === 'CONNECTION_ERROR') {\n\t\t\t\t\tif (error.data.service === 'IMAP') {\n\t\t\t\t\t\tthis.feedback = t('mail', 'IMAP server is not reachable')\n\t\t\t\t\t} else if (error.data.service === 'SMTP') {\n\t\t\t\t\t\tthis.feedback = t('mail', 'SMTP server is not reachable')\n\t\t\t\t\t}\n\t\t\t\t} else if (error.data?.error === 'AUTHENTICATION_WRONG_PASSWORD') {\n\t\t\t\t\tif (error.data.service === 'IMAP') {\n\t\t\t\t\t\tthis.feedback = t('mail', 'IMAP username or password is wrong')\n\t\t\t\t\t} else if (error.data.service === 'SMTP') {\n\t\t\t\t\t\tthis.feedback = t('mail', 'SMTP username or password is wrong')\n\t\t\t\t\t}\n\t\t\t\t} else if (error.data?.error === 'AUTHENTICATION_DENIED') {\n\t\t\t\t\tif (error.data.service === 'IMAP') {\n\t\t\t\t\t\tthis.feedback = t('mail', 'IMAP server denied authentication')\n\t\t\t\t\t} else if (error.data.service === 'SMTP') {\n\t\t\t\t\t\tthis.feedback = t('mail', 'SMTP server denied authentication')\n\t\t\t\t\t}\n\t\t\t\t} else if (error.data?.error === 'AUTHENTICATION') {\n\t\t\t\t\tif (error.data.service === 'IMAP') {\n\t\t\t\t\t\tthis.feedback = t('mail', 'IMAP authentication error')\n\t\t\t\t\t} else if (error.data.service === 'SMTP') {\n\t\t\t\t\t\tthis.feedback = t('mail', 'SMTP authentication error')\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (error.data?.service === 'IMAP') {\n\t\t\t\t\t\tthis.feedback = t('mail', 'IMAP connection failed')\n\t\t\t\t\t} else if (error.data?.service === 'SMTP') {\n\t\t\t\t\t\tthis.feedback = t('mail', 'SMTP connection failed')\n\t\t\t\t\t} else if (error.message === CONSENT_ABORTED) {\n\t\t\t\t\t\tthis.feedback = t('mail', 'Authorization pop-up closed')\n\t\t\t\t\t} else if (error.response?.status === 429) {\n\t\t\t\t\t\tthis.feedback = t('mail', 'Configuration discovery temporarily not available. Please try again later.')\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.feedback = t('mail', 'There was an error while setting up your account')\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tthis.loading = false\n\t\t\t\tthis.loadingMessage = undefined\n\t\t\t}\n\t\t},\n\n\t\tisValidEmail(email) {\n\t\t\tconst regExpEmail = /^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@(localhost|((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,})))$/\n\t\t\treturn regExpEmail.test(email)\n\t\t},\n\t},\n}\n<\/script>\n\n<style lang=\"scss\" scoped>\n:deep(.tabs-component-tabs) {\n\tdisplay: flex;\n}\n\n:deep(.tabs-component-tab) {\n\tflex-grow: 1;\n\ttext-align: center;\n\tcolor: var(--color-text-lighter);\n\tmargin-bottom: calc(var(--default-grid-baseline) * 2 + var(--default-grid-baseline) / 2);\n}\n\n:deep(.tabs-component-tab.is-active) {\n\tborder-bottom: var(--border-width-input) solid black;\n\tfont-weight: bold;\n}\n\n:deep(.input-field) {\n\tmargin: calc(var(--default-grid-baseline) * 3) 0;\n}\n\n.tabs-component-panels {\n\tpadding-top: calc(var(--default-grid-baseline) * 5);\n}\n\n.tabs-component-panels label {\n\ttext-align: start;\n\twidth: 100%;\n\tdisplay: inline-block;\n}\n\n.tabs-component-panels input,\n.tabs-component-panels select {\n\tmargin-bottom: calc(var(--default-grid-baseline) * 2);\n}\n</style>\n\n<style scoped>\nh4 {\n\ttext-align: start;\n}\n\n.flex-row {\n\tdisplay: flex;\n}\n\ninput.primary {\n\tcolor: var(--color-main-background);\n}\n\ninput[type='radio'] {\n\tdisplay: none;\n}\n\ninput[type='radio'][disabled] + label {\n\tcursor: default;\n\topacity: 0.5;\n}\n\n.account-form__label--required:after {\n\tcontent:\" *\";\n}\n\n.account-form__heading--required:after {\n\tcontent:\" *\";\n}\n\n.account-form__submit-buttons {\n\tdisplay: flex;\n\tjustify-content: center;\n\tmargin-top: var(--default-grid-baseline);\n}\n\n.account-form__submit-button {\n\tdisplay: flex;\n\talign-items: center;\n}\n\n.account-form--feedback {\n\tcolor: var(--color-text-maxcontrast);\n\tmargin-top: var(--default-grid-baseline);\n\ttext-align: center;\n}\n\n.account-form--error {\n\ttext-align: start;\n\tfont-size: 14px;\n}\n\n#account-form {\n\tz-index: 1001;\n\twidth: 300px;\n\ttop: 15%;\n\tpadding-bottom: calc(var(--default-grid-baseline) * 12);\n\tmargin: 0 auto;\n\tpadding-top: calc(var(--default-grid-baseline) * 7);\n}\n\n#account-form input {\n\twidth: 100%;\n\tbox-sizing: border-box;\n}\n</style>\n"],sourceRoot:""}]);const l=s},69271:(t,n,a)=>{a.d(n,{A:()=>l});var e=a(71354),i=a.n(e),o=a(76314),s=a.n(o)()(i());s.push([t.id,"[data-v-89aa13e4] .tabs-component-tabs{display:flex}[data-v-89aa13e4] .tabs-component-tab{flex-grow:1;text-align:center;color:var(--color-text-lighter);margin-bottom:calc(var(--default-grid-baseline)*2 + var(--default-grid-baseline)/2)}[data-v-89aa13e4] .tabs-component-tab.is-active{border-bottom:var(--border-width-input) solid #000;font-weight:bold}[data-v-89aa13e4] .input-field{margin:calc(var(--default-grid-baseline)*3) 0}.tabs-component-panels[data-v-89aa13e4]{padding-top:calc(var(--default-grid-baseline)*5)}.tabs-component-panels label[data-v-89aa13e4]{text-align:start;width:100%;display:inline-block}.tabs-component-panels input[data-v-89aa13e4],.tabs-component-panels select[data-v-89aa13e4]{margin-bottom:calc(var(--default-grid-baseline)*2)}","",{version:3,sources:["webpack://./src/components/AccountForm.vue"],names:[],mappings:"AACA,uCACC,YAAA,CAGD,sCACC,WAAA,CACA,iBAAA,CACA,+BAAA,CACA,mFAAA,CAGD,gDACC,kDAAA,CACA,gBAAA,CAGD,+BACC,6CAAA,CAGD,wCACC,gDAAA,CAGD,8CACC,gBAAA,CACA,UAAA,CACA,oBAAA,CAGD,6FAEC,kDAAA",sourcesContent:["\n:deep(.tabs-component-tabs) {\n\tdisplay: flex;\n}\n\n:deep(.tabs-component-tab) {\n\tflex-grow: 1;\n\ttext-align: center;\n\tcolor: var(--color-text-lighter);\n\tmargin-bottom: calc(var(--default-grid-baseline) * 2 + var(--default-grid-baseline) / 2);\n}\n\n:deep(.tabs-component-tab.is-active) {\n\tborder-bottom: var(--border-width-input) solid black;\n\tfont-weight: bold;\n}\n\n:deep(.input-field) {\n\tmargin: calc(var(--default-grid-baseline) * 3) 0;\n}\n\n.tabs-component-panels {\n\tpadding-top: calc(var(--default-grid-baseline) * 5);\n}\n\n.tabs-component-panels label {\n\ttext-align: start;\n\twidth: 100%;\n\tdisplay: inline-block;\n}\n\n.tabs-component-panels input,\n.tabs-component-panels select {\n\tmargin-bottom: calc(var(--default-grid-baseline) * 2);\n}\n"],sourceRoot:""}]);const l=s},80772:(t,n,a)=>{a.d(n,{A:()=>E});var e=a(53334),i=a(71112),o=a(51849),s=a(54165),l=a(90629),r=a(85745);const c="OAUTH_CONSENT_ABORTED";async function d(t){const n=window.open(t,(0,e.Tl)("mail","Connect OAUTH2 account"),"toolbar=no, menubar=no, width=600, height=700");n.focus(),await new Promise(((t,a)=>{window.addEventListener("message",(a=>{const{data:e}=a;r.A.debug("Child window message received",{event:a}),"DONE"===e&&(r.A.info("OAUTH2 user consent given"),n.close(),t())}));const e=setInterval((()=>{n.closed&&(clearInterval(e),a(new Error(c)))}),200)}))}var u=a(66802),m=a(63814);async function p(t,n){return(await u.Ay.get((0,m.Jv)("/apps/mail/api/autoconfig/ispdb/{host}/{email}",{host:t,email:n}))).data.data}async function h(t,n){return(await u.Ay.get((0,m.Jv)("/apps/mail/api/autoconfig/test?host={host}&port={port}",{host:t,port:n}))).data.data}var g=a(49519);function f(t,n){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);n&&(e=e.filter((function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable}))),a.push.apply(a,e)}return a}function A(t){for(var n=1;n<arguments.length;n++){var a=null!=arguments[n]?arguments[n]:{};n%2?f(Object(a),!0).forEach((function(n){b(t,n,a[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):f(Object(a)).forEach((function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(a,n))}))}return t}function b(t,n,a){return(n=function(t){var n=function(t){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var a=n.call(t,"string");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof n?n:n+""}(n))in t?Object.defineProperty(t,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[n]=a,t}const C={name:"AccountForm",components:{NcPasswordField:i.b9,NcInputField:i.Es,NcCheckboxRadioSwitch:i.AO,Tab:s.Tab,Tabs:s.Tabs,ButtonVue:i.x1,IconLoading:i.ne,IconCheck:l.A},props:{displayName:{type:String,default:""},email:{type:String,default:""},account:{type:Object,required:!1,default:()=>{}}},data(){const t=(t,n)=>void 0!==this.account?this.account[t]:n;return{loading:!1,loadingMessage:void 0,mode:"auto",accountName:this.displayName,emailAddress:this.email,autoConfig:{password:""},manualConfig:{imapHost:t("imapHost",""),imapPort:t("imapPort",993),imapSslMode:t("imapSslMode","ssl"),imapUser:t("imapUser",""),imapPassword:"",smtpHost:t("smtpHost",""),smtpPort:t("smtpPort",587),smtpSslMode:t("smtpSslMode","tls"),smtpUser:t("smtpUser",""),smtpPassword:""},feedback:null,password:""}},computed:A(A(A({},(0,o.n2)(g.A)),(0,o.aH)(g.A,["googleOauthUrl","microsoftOauthUrl"])),{},{settingsPage(){return void 0!==this.account},isDisabledAuto(){return!!this.loading||("auto"!==this.mode?this.loading:!this.emailAddress||!this.isValidEmail(this.emailAddress)||!this.googleOauthUrl&&!this.autoConfig.password||!this.microsoftOauthUrl&&!this.autoConfig.password)},isDisabledManual(){return!!this.loading||("manual"!==this.mode?this.loading:!(this.emailAddress&&this.isValidEmail(this.emailAddress)&&this.manualConfig.imapHost&&this.manualConfig.imapPort&&this.manualConfig.imapUser&&(this.useOauth||this.manualConfig.imapPassword)&&this.manualConfig.smtpHost&&this.manualConfig.smtpPort&&this.manualConfig.smtpUser&&(this.useOauth||this.manualConfig.smtpPassword)))},isGoogleAccount(){return"imap.gmail.com"===this.manualConfig.imapHost||"smtp.gmail.com"===this.manualConfig.smtpHost},isMicrosoftAccount(){return"outlook.office365.com"===this.manualConfig.imapHost||"outlook.office365.com"===this.manualConfig.smtpHost},hasPasswordAlternatives(){return!!this.googleOauthUrl||!!this.microsoftOauthUrl},useOauth(){return this.isGoogleAccount&&this.googleOauthUrl||this.isMicrosoftAccount&&this.microsoftOauthUrl},submitButtonText(){var t;return this.loading?null!==(t=this.loadingMessage)&&void 0!==t?t:(0,e.Tl)("mail","Connecting"):"manual"===this.mode&&this.useOauth?this.isGoogleAccount?this.account?(0,e.Tl)("mail","Reconnect Google account"):(0,e.Tl)("mail","Sign in with Google"):this.account?(0,e.Tl)("mail","Reconnect Microsoft account"):(0,e.Tl)("mail","Sign in with Microsoft"):this.account?(0,e.Tl)("mail","Save"):(0,e.Tl)("mail","Connect")}}),methods:{onModeChanged(t){this.mode=t.tab.id,"manual"===this.mode&&(""===this.manualConfig.imapUser&&(this.manualConfig.imapUser=this.emailAddress),""===this.manualConfig.imapPassword&&(this.manualConfig.imapPassword=this.autoConfig.password),""===this.manualConfig.smtpUser&&(this.manualConfig.smtpUser=this.emailAddress),""===this.manualConfig.smtpPassword&&(this.manualConfig.smtpPassword=this.autoConfig.password))},onImapSslModeChange(t){switch(this.clearFeedback(),this.manualConfig.imapSslMode=t,this.manualConfig.imapSslMode){case"none":case"tls":this.manualConfig.imapPort=143;break;case"ssl":this.manualConfig.imapPort=993}},onSmtpSslModeChange(t){switch(this.clearFeedback(),this.manualConfig.smtpSslMode=t,this.manualConfig.smtpSslMode){case"none":case"tls":this.manualConfig.smtpPort=587;break;case"ssl":this.manualConfig.smtpPort=465}},clearFeedback(){this.feedback=null},applyAutoConfig(t){return!!t&&(null!=t&&t.imapConfig&&(this.manualConfig.imapUser=t.imapConfig.username,this.manualConfig.imapHost=t.imapConfig.host,this.manualConfig.imapPort=t.imapConfig.port,this.manualConfig.imapSslMode=t.imapConfig.security,this.manualConfig.imapPassword=this.autoConfig.password),null!=t&&t.smtpConfig&&(this.manualConfig.smtpUser=t.smtpConfig.username,this.manualConfig.smtpHost=t.smtpConfig.host,this.manualConfig.smtpPort=t.smtpConfig.port,this.manualConfig.smtpSslMode=t.smtpConfig.security,this.manualConfig.smtpPassword=this.autoConfig.password),!0)},async detectConfig(){this.loadingMessage=(0,e.Tl)("mail","Looking up configuration");const t=await p(this.emailAddress.split("@").pop(),this.emailAddress);if(r.A.debug("fetched auto config",{config:t}),this.applyAutoConfig(t))return r.A.debug("ISP DB config applied"),!0;{const t=await async function(t){return(await u.Ay.get((0,m.Jv)("/apps/mail/api/autoconfig/mx/{email}",{email:t}))).data.data}(this.emailAddress);if(r.A.debug("MX hosts fetched",{mxHosts:t}),t.length){const n=t[0].split(".").splice(-2).join(".").toLowerCase(),a=await p(n,this.emailAddress);if(r.A.debug("fetched MX auto config",{mxConfig:a}),a&&this.applyAutoConfig(a))return!0}this.loadingMessage=(0,e.Tl)("mail","Checking mail host connectivity");const n=t.slice(0,1).flatMap((t=>[993,143,465,587].map((n=>({host:t,port:n}))))),a=await Promise.all(n.map((async t=>{let{host:n,port:a}=t;return{host:n,port:a,canConnect:await h(n,a)}}))),i=a.filter((t=>{let{canConnect:n,port:a}=t;return n&&993===a}))[0],o=a.filter((t=>{let{canConnect:n,port:a}=t;return n&&[465,587].includes(a)}))[0];return r.A.debug("MX connectivity tested",{firstImapHost:i,firstSmtpHost:o}),i&&o?(this.applyAutoConfig({imapConfig:{username:this.emailAddress,host:i.host,port:i.port,security:993===i.port?"ssl":"tls"},smtpConfig:{username:this.emailAddress,host:o.host,port:o.port,security:465===o.port?"ssl":"tls"}}),!0):(this.feedback=(0,e.Tl)("mail","Configuration discovery failed. Please use the manual settings"),!1)}},async onSubmit(t){if(r.A.debug("account form submitted",{event:t}),this.isDisabledManual||this.isDisabledAuto)r.A.warn("submit is disabled");else{this.clearFeedback(),this.loading=!0;try{if("auto"===this.mode&&!await this.detectConfig())return void r.A.warn("Auto mode failed");if(!this.useOauth){if("auto"===this.mode&&""===this.autoConfig.password)return void(this.feedback=(0,e.Tl)("mail","Password required"));if("manual"===this.mode&&(""===this.manualConfig.imapPassword||""===this.manualConfig.smtpPassword))return void(this.feedback=(0,e.Tl)("mail","Password required"))}this.loadingMessage=(0,e.Tl)("mail","Testing authentication");const t=A(A({},this.manualConfig),{},{accountName:this.accountName,emailAddress:this.emailAddress,imapHost:this.manualConfig.imapHost.trim(),smtpHost:this.manualConfig.smtpHost.trim(),authMethod:this.useOauth?"xoauth2":"password"});if(this.useOauth&&(delete t.imapPassword,delete t.smtpPassword),this.account){const n=this.account,a=await this.mainStore.updateAccount(A(A({},t),{},{accountId:this.account.id}));if(this.useOauth){this.loadingMessage=(0,e.Tl)("mail","Awaiting user consent");try{this.isGoogleAccount?(this.feedback=(0,e.Tl)("mail","Account updated. Please follow the pop-up instructions to reconnect your Google account"),await d(this.googleOauthUrl.replace("_accountId_",a.id).replace("_email_",encodeURIComponent(a.emailAddress)))):(this.feedback=(0,e.Tl)("mail","Account updated. Please follow the pop-up instructions to reconnect your Microsoft account"),await d(this.microsoftOauthUrl.replace("_accountId_",a.id).replace("_email_",encodeURIComponent(a.emailAddress))))}catch(t){throw await this.mainStore.updateAccount(A(A({},n),{},{accountId:n.id})),r.A.info("Account ".concat(a.id," update undone")),t}this.clearFeedback()}this.feedback=(0,e.Tl)("mail","Account updated")}else{const n=await this.mainStore.startAccountSetup(t);if(this.useOauth){this.loadingMessage=(0,e.Tl)("mail","Awaiting user consent");try{this.isGoogleAccount?(this.feedback=(0,e.Tl)("mail","Account created. Please follow the pop-up instructions to link your Google account"),await d(this.googleOauthUrl.replace("_accountId_",n.id).replace("_email_",encodeURIComponent(n.emailAddress)))):(this.feedback=(0,e.Tl)("mail","Account created. Please follow the pop-up instructions to link your Microsoft account"),await d(this.microsoftOauthUrl.replace("_accountId_",n.id).replace("_email_",encodeURIComponent(n.emailAddress))))}catch(t){throw this.mainStore.deleteAccount(n),r.A.info("Temporary account ".concat(n.id," deleted")),t}this.clearFeedback()}this.loadingMessage=(0,e.Tl)("mail","Loading account"),await this.mainStore.finishAccountSetup({account:n}),this.$emit("account-created",n)}}catch(t){var n,a,i,o;if(r.A.error("could not save account details",{error:t}),"CONNECTION_ERROR"===(null===(n=t.data)||void 0===n?void 0:n.error))"IMAP"===t.data.service?this.feedback=(0,e.Tl)("mail","IMAP server is not reachable"):"SMTP"===t.data.service&&(this.feedback=(0,e.Tl)("mail","SMTP server is not reachable"));else if("AUTHENTICATION_WRONG_PASSWORD"===(null===(a=t.data)||void 0===a?void 0:a.error))"IMAP"===t.data.service?this.feedback=(0,e.Tl)("mail","IMAP username or password is wrong"):"SMTP"===t.data.service&&(this.feedback=(0,e.Tl)("mail","SMTP username or password is wrong"));else if("AUTHENTICATION_DENIED"===(null===(i=t.data)||void 0===i?void 0:i.error))"IMAP"===t.data.service?this.feedback=(0,e.Tl)("mail","IMAP server denied authentication"):"SMTP"===t.data.service&&(this.feedback=(0,e.Tl)("mail","SMTP server denied authentication"));else if("AUTHENTICATION"===(null===(o=t.data)||void 0===o?void 0:o.error))"IMAP"===t.data.service?this.feedback=(0,e.Tl)("mail","IMAP authentication error"):"SMTP"===t.data.service&&(this.feedback=(0,e.Tl)("mail","SMTP authentication error"));else{var s,l,u;"IMAP"===(null===(s=t.data)||void 0===s?void 0:s.service)?this.feedback=(0,e.Tl)("mail","IMAP connection failed"):"SMTP"===(null===(l=t.data)||void 0===l?void 0:l.service)?this.feedback=(0,e.Tl)("mail","SMTP connection failed"):t.message===c?this.feedback=(0,e.Tl)("mail","Authorization pop-up closed"):429===(null===(u=t.response)||void 0===u?void 0:u.status)?this.feedback=(0,e.Tl)("mail","Configuration discovery temporarily not available. Please try again later."):this.feedback=(0,e.Tl)("mail","There was an error while setting up your account")}}finally{this.loading=!1,this.loadingMessage=void 0}}},isValidEmail:t=>/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@(localhost|((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,})))$/.test(t)}};var v=a(85072),w=a.n(v),P=a(97825),S=a.n(P),y=a(77659),M=a.n(y),k=a(55056),T=a.n(k),_=a(10540),I=a.n(_),x=a(41113),N=a.n(x),O=a(69271),U={};U.styleTagTransform=N(),U.setAttributes=T(),U.insert=M().bind(null,"head"),U.domAPI=S(),U.insertStyleElement=I(),w()(O.A,U),O.A&&O.A.locals&&O.A.locals;var H=a(38281),F={};F.styleTagTransform=N(),F.setAttributes=T(),F.insert=M().bind(null,"head"),F.domAPI=S(),F.insertStyleElement=I(),w()(H.A,F),H.A&&H.A.locals&&H.A.locals;const E=(0,a(14486).A)(C,(function(){var t=this,n=t._self._c;return n("form",{attrs:{id:"account-form"},on:{submit:function(n){return n.preventDefault(),t.onSubmit.apply(null,arguments)}}},[n("Tabs",{attrs:{options:{useUrlFragment:!1,defaultTabHash:t.settingsPage?"manual":"auto"},"cache-lifetime":"0"},on:{changed:t.onModeChanged}},[n("Tab",{key:"auto",attrs:{id:"auto",name:t.t("mail","Auto")}},[n("NcInputField",{attrs:{id:"auto-name",value:t.accountName,label:t.t("mail","Name"),type:"text",placeholder:t.t("mail","Name"),disabled:t.loading,autofocus:""},on:{"update:value":function(n){t.accountName=n}}}),t._v(" "),n("NcInputField",{attrs:{id:"auto-address",value:t.emailAddress,label:t.t("mail","Mail address"),disabled:t.loading,placeholder:t.t("mail","name@example.org"),required:"",type:"email"},on:{"update:value":function(n){t.emailAddress=n},change:t.clearFeedback}}),t._v(" "),t.isValidEmail(t.emailAddress)?t._e():n("p",{staticClass:"account-form--error"},[t._v("\n\t\t\t\t"+t._s(t.t("mail","Please enter an email of the format name@example.com"))+"\n\t\t\t")]),t._v(" "),n("NcPasswordField",{attrs:{id:"auto-password",value:t.autoConfig.password,disabled:t.loading,type:"password",label:t.t("mail","Password"),required:!t.hasPasswordAlternatives},on:{"update:value":function(n){return t.$set(t.autoConfig,"password",n)},change:t.clearFeedback}})],1),t._v(" "),n("Tab",{key:"manual",attrs:{id:"manual",name:t.t("mail","Manual")}},[n("NcInputField",{attrs:{id:"man-name",value:t.accountName,label:t.t("mail","Name"),type:"text",placeholder:t.t("mail","Name"),disabled:t.loading},on:{"update:value":function(n){t.accountName=n}}}),t._v(" "),n("NcInputField",{attrs:{id:"man-address",value:t.emailAddress,label:t.t("mail","Mail address"),type:"email",placeholder:t.t("mail","name@example.org"),disabled:t.loading,required:""},on:{"update:value":function(n){t.emailAddress=n},change:t.clearFeedback}}),t._v(" "),t.isValidEmail(t.emailAddress)?t._e():n("p",{staticClass:"account-form--error"},[t._v("\n\t\t\t\t"+t._s(t.t("mail","Please enter an email of the format name@example.com"))+"\n\t\t\t")]),t._v(" "),n("h3",[t._v(t._s(t.t("mail","IMAP Settings")))]),t._v(" "),n("NcInputField",{attrs:{id:"man-imap-host",value:t.manualConfig.imapHost,label:t.t("mail","IMAP Host"),type:"text",placeholder:t.t("mail","IMAP Host"),disabled:t.loading,required:""},on:{"update:value":function(n){return t.$set(t.manualConfig,"imapHost",n)},change:t.clearFeedback}}),t._v(" "),n("h4",{staticClass:"account-form__heading--required"},[t._v("\n\t\t\t\t"+t._s(t.t("mail","IMAP Security"))+"\n\t\t\t")]),t._v(" "),n("div",{staticClass:"flex-row"},[n("NcCheckboxRadioSwitch",{attrs:{id:"man-imap-sec-none","button-variant":!0,checked:t.manualConfig.imapSslMode,type:"radio",name:"man-imap-sec",disabled:t.loading,value:"none","button-variant-grouped":"horizontal"},on:{"update:checked":t.onImapSslModeChange}},[t._v("\n\t\t\t\t\t"+t._s(t.t("mail","None"))+"\n\t\t\t\t")]),t._v(" "),n("NcCheckboxRadioSwitch",{attrs:{id:"man-imap-sec-ssl","button-variant":!0,checked:t.manualConfig.imapSslMode,type:"radio",name:"man-imap-sec",disabled:t.loading,value:"ssl","button-variant-grouped":"horizontal"},on:{"update:checked":t.onImapSslModeChange}},[t._v("\n\t\t\t\t\t"+t._s(t.t("mail","SSL/TLS"))+"\n\t\t\t\t")]),t._v(" "),n("NcCheckboxRadioSwitch",{attrs:{id:"man-imap-sec-tls","button-variant":!0,checked:t.manualConfig.imapSslMode,type:"radio",name:"man-imap-sec",disabled:t.loading,value:"tls","button-variant-grouped":"horizontal"},on:{"update:checked":t.onImapSslModeChange}},[t._v("\n\t\t\t\t\t"+t._s(t.t("mail","STARTTLS"))+"\n\t\t\t\t")])],1),t._v(" "),n("NcInputField",{attrs:{id:"man-imap-port",value:t.manualConfig.imapPort,label:t.t("mail","IMAP Port"),type:"number",placeholder:t.t("mail","IMAP Port"),disabled:t.loading,required:""},on:{"update:value":function(n){return t.$set(t.manualConfig,"imapPort",n)},change:t.clearFeedback}}),t._v(" "),n("NcInputField",{attrs:{id:"man-imap-user",value:t.manualConfig.imapUser,label:t.t("mail","IMAP User"),type:"text",placeholder:t.t("mail","IMAP User"),disabled:t.loading,required:""},on:{"update:value":function(n){return t.$set(t.manualConfig,"imapUser",n)},change:t.clearFeedback}}),t._v(" "),t.useOauth?t._e():n("NcPasswordField",{attrs:{id:"man-imap-password",type:"password",value:t.manualConfig.imapPassword,label:t.t("mail","IMAP Password"),disabled:t.loading,required:""},on:{"update:value":function(n){return t.$set(t.manualConfig,"imapPassword",n)},change:t.clearFeedback}}),t._v(" "),n("h3",[t._v(t._s(t.t("mail","SMTP Settings")))]),t._v(" "),n("NcInputField",{ref:"smtpHost",attrs:{id:"man-smtp-host",value:t.manualConfig.smtpHost,label:t.t("mail","SMTP Host"),type:"text",name:"smtp-host",placeholder:t.t("mail","SMTP Host"),disabled:t.loading,required:""},on:{"update:value":function(n){return t.$set(t.manualConfig,"smtpHost",n)},change:t.clearFeedback}}),t._v(" "),n("h4",{staticClass:"account-form__heading--required"},[t._v("\n\t\t\t\t"+t._s(t.t("mail","SMTP Security"))+"\n\t\t\t")]),t._v(" "),n("div",{staticClass:"flex-row"},[n("NcCheckboxRadioSwitch",{attrs:{id:"man-imap-sec-none","button-variant":!0,checked:t.manualConfig.smtpSslMode,type:"radio",name:"man-smtp-sec",disabled:t.loading,value:"none","button-variant-grouped":"horizontal"},on:{"update:checked":t.onSmtpSslModeChange}},[t._v("\n\t\t\t\t\t"+t._s(t.t("mail","None"))+"\n\t\t\t\t")]),t._v(" "),n("NcCheckboxRadioSwitch",{attrs:{id:"man-imap-sec-ssl","button-variant":!0,checked:t.manualConfig.smtpSslMode,type:"radio",name:"man-smtp-sec",disabled:t.loading,value:"ssl","button-variant-grouped":"horizontal"},on:{"update:checked":t.onSmtpSslModeChange}},[t._v("\n\t\t\t\t\t"+t._s(t.t("mail","SSL/TLS"))+"\n\t\t\t\t")]),t._v(" "),n("NcCheckboxRadioSwitch",{attrs:{id:"man-imap-sec-tls","button-variant":!0,checked:t.manualConfig.smtpSslMode,type:"radio",name:"man-smtp-sec",disabled:t.loading,value:"tls","button-variant-grouped":"horizontal"},on:{"update:checked":t.onSmtpSslModeChange}},[t._v("\n\t\t\t\t\t"+t._s(t.t("mail","STARTTLS"))+"\n\t\t\t\t")])],1),t._v(" "),n("NcInputField",{attrs:{id:"man-smtp-port",label:t.t("mail","SMTP Port"),value:t.manualConfig.smtpPort,type:"number",placeholder:t.t("mail","SMTP Port"),disabled:t.loading,required:""},on:{"update:value":function(n){return t.$set(t.manualConfig,"smtpPort",n)},change:t.clearFeedback}}),t._v(" "),n("NcInputField",{attrs:{id:"man-smtp-user",value:t.manualConfig.smtpUser,label:t.t("mail","SMTP User"),type:"text",placeholder:t.t("mail","SMTP User"),disabled:t.loading,required:""},on:{"update:value":function(n){return t.$set(t.manualConfig,"smtpUser",n)},change:t.clearFeedback}}),t._v(" "),t.useOauth?t._e():n("NcPasswordField",{attrs:{id:"man-smtp-password",label:t.t("mail","SMTP Password"),type:"password",value:t.manualConfig.smtpPassword,disabled:t.loading,required:""},on:{"update:value":function(n){return t.$set(t.manualConfig,"smtpPassword",n)},change:t.clearFeedback}})],1)],1),t._v(" "),t.isGoogleAccount&&!t.googleOauthUrl?n("div",{staticClass:"account-form__google-sso"},[t._v("\n\t\t"+t._s(t.t("mail","For the Google account to work with this app you need to enable two-factor authentication for Google and generate an app password."))+"\n\t")]):t._e(),t._v(" "),n("div",{staticClass:"account-form__submit-buttons"},["auto"===t.mode?n("ButtonVue",{staticClass:"account-form__submit-button",attrs:{"aria-label":t.submitButtonText,type:"primary","native-type":"submit",disabled:t.isDisabledAuto||t.loading},on:{click:function(n){return n.preventDefault(),t.onSubmit.apply(null,arguments)}},scopedSlots:t._u([{key:"icon",fn:function(){return[t.loading?n("IconLoading",{attrs:{size:20}}):n("IconCheck",{attrs:{size:20}})]},proxy:!0}],null,!1,4145190044)},[t._v("\n\t\t\t"+t._s(t.submitButtonText)+"\n\t\t")]):"manual"===t.mode?n("ButtonVue",{staticClass:"account-form__submit-button",attrs:{"aria-label":t.submitButtonText,type:"primary","native-type":"submit",disabled:t.isDisabledManual||t.loading},on:{click:function(n){return n.preventDefault(),t.onSubmit.apply(null,arguments)}},scopedSlots:t._u([{key:"icon",fn:function(){return[t.loading?n("IconLoading",{attrs:{size:20}}):n("IconCheck",{attrs:{size:20}})]},proxy:!0}])},[t._v("\n\t\t\t"+t._s(t.submitButtonText)+"\n\t\t")]):t._e()],1),t._v(" "),t.feedback?n("div",{staticClass:"account-form--feedback"},[t._v("\n\t\t"+t._s(t.feedback)+"\n\t")]):t._e()],1)}),[],!1,null,"89aa13e4",null).exports}}]);
|
|
//# sourceMappingURL=mail.772.4d13d1107c3e24415dd2.js.map
|