n8n-editor-ui
Version:
Workflow Editor UI for n8n
105 lines (104 loc) • 3.54 kB
JavaScript
import { C as computed, It as ref, P as defineComponent, T as createBlock, et as openBlock } from "./vue.runtime.esm-bundler-tP5dCd7J.js";
import { gt as useI18n } from "./_MapCache-B159LOu5.js";
import "./src-BW7zuOU1.js";
import "./en-b3uD8cvU.js";
import "./preload-helper-CR0ecmWK.js";
import "./_plugin-vue_export-helper-BwBpWJRZ.js";
import "./truncate-Dc5upPom.js";
import "./icon-MZ_3fB_h.js";
import "./empty-4-N75rxI.js";
import { Ho as useSettingsStore, nr as useUsersStore } from "./useTelemetry-C797TaYa.js";
import { t as useToast } from "./useToast-ZaUhbG9w.js";
import "./sanitize-html-CgpOSgtK.js";
import "./CalendarDate-DxkU3CHY.js";
import "./path-browserify-B5h_dP_u.js";
import "./constants-CX1ozgFz.js";
import "./merge-BArJwbQo.js";
import "./_baseOrderBy-DL6Sy5xK.js";
import "./dateformat-CMLc6OKJ.js";
import "./useDebounce-RgPaX171.js";
import "./useExternalHooks-CYMS6JpD.js";
import "./useStyles-DhM0cpS7.js";
import "./sso.store-B_c2j1dV.js";
import { t as AuthView_default } from "./AuthView-DDyHoJhx.js";
var ForgotMyPasswordView_default = /* @__PURE__ */ defineComponent({
__name: "ForgotMyPasswordView",
setup(__props) {
const settingsStore = useSettingsStore();
const usersStore = useUsersStore();
const toast = useToast();
const locale = useI18n();
const loading = ref(false);
const formConfig = computed(() => {
const EMAIL_INPUTS = [{
name: "email",
properties: {
label: locale.baseText("auth.email"),
type: "email",
required: true,
validationRules: [{ name: "VALID_EMAIL" }],
autocomplete: "email",
capitalize: true,
focusInitially: true
}
}];
const NO_SMTP_INPUTS = [{
name: "no-smtp-warning",
properties: {
label: locale.baseText("forgotPassword.noSMTPToSendEmailWarning"),
type: "info"
}
}];
const DEFAULT_FORM_CONFIG = {
title: locale.baseText("forgotPassword.recoverPassword"),
redirectText: locale.baseText("forgotPassword.returnToSignIn"),
redirectLink: "/signin"
};
if (settingsStore.isSmtpSetup) return {
...DEFAULT_FORM_CONFIG,
buttonText: locale.baseText("forgotPassword.getRecoveryLink"),
inputs: EMAIL_INPUTS
};
return {
...DEFAULT_FORM_CONFIG,
inputs: NO_SMTP_INPUTS
};
});
const isFormWithEmail = (values) => {
return "email" in values;
};
const onSubmit = async (values) => {
if (!isFormWithEmail(values)) return;
try {
loading.value = true;
await usersStore.sendForgotPasswordEmail(values);
toast.showMessage({
type: "success",
title: locale.baseText("forgotPassword.recoveryEmailSent"),
message: locale.baseText("forgotPassword.emailSentIfExists", { interpolate: { email: values.email } })
});
} catch (error) {
let message = locale.baseText("forgotPassword.smtpErrorContactAdministrator");
if (error.httpStatusCode) {
const { httpStatusCode: status } = error;
if (status === 429) message = locale.baseText("forgotPassword.tooManyRequests");
else if (error.httpStatusCode === 422) message = locale.baseText(error.message);
toast.showMessage({
type: "error",
title: locale.baseText("forgotPassword.sendingEmailError"),
message
});
}
}
loading.value = false;
};
return (_ctx, _cache) => {
return openBlock(), createBlock(AuthView_default, {
form: formConfig.value,
"form-loading": loading.value,
onSubmit
}, null, 8, ["form", "form-loading"]);
};
}
});
export { ForgotMyPasswordView_default as default };