n8n-editor-ui
Version:
Workflow Editor UI for n8n
101 lines (100 loc) • 3.4 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 { _t as useI18n } from "./_MapCache-ficiegRb.js";
import "./src-DgvumQTi.js";
import "./en-CF30SCh2.js";
import "./preload-helper-CR0ecmWK.js";
import "./_plugin-vue_export-helper-BwBpWJRZ.js";
import "./truncate-B1HVeveJ.js";
import { Dr as useUsersStore, gs as useSettingsStore, v as useToast } from "./builder.store-sBTWwxRU.js";
import "./empty-BuGRxzl4.js";
import "./sanitize-html-Cc45ZKm8.js";
import "./CalendarDate-zWqgZMlk.js";
import "./path-browserify-BtCDmZ3_.js";
import "./constants-BbpucWL4.js";
import "./merge-k8vSyyXH.js";
import "./_baseOrderBy-B_6CV8x6.js";
import "./dateformat-CM9k0--B.js";
import "./useDebounce-Bnb8W2LR.js";
import "./sso.store-Ba2eVE3K.js";
import { t as AuthView_default } from "./AuthView-TY21M5Xw.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 };