mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-22 12:19:09 +00:00
fix(core): Do not validate email when LDAP is enabled (#13605)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type {
|
||||
LoginRequestDto,
|
||||
PasswordUpdateRequestDto,
|
||||
SettingsUpdateRequestDto,
|
||||
UserUpdateRequestDto,
|
||||
@@ -21,7 +22,7 @@ export async function loginCurrentUser(
|
||||
|
||||
export async function login(
|
||||
context: IRestApiContext,
|
||||
params: { email: string; password: string; mfaCode?: string; mfaRecoveryToken?: string },
|
||||
params: LoginRequestDto,
|
||||
): Promise<CurrentUserResponse> {
|
||||
return await makeRestApiRequest(context, 'POST', '/login', params);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type {
|
||||
LoginRequestDto,
|
||||
PasswordUpdateRequestDto,
|
||||
SettingsUpdateRequestDto,
|
||||
UserUpdateRequestDto,
|
||||
@@ -181,12 +182,7 @@ export const useUsersStore = defineStore(STORES.USERS, () => {
|
||||
};
|
||||
};
|
||||
|
||||
const loginWithCreds = async (params: {
|
||||
email: string;
|
||||
password: string;
|
||||
mfaCode?: string;
|
||||
mfaRecoveryCode?: string;
|
||||
}) => {
|
||||
const loginWithCreds = async (params: LoginRequestDto) => {
|
||||
const user = await usersApi.login(rootStore.restApiContext, params);
|
||||
if (!user) {
|
||||
return;
|
||||
|
||||
@@ -3,6 +3,7 @@ import Logo from '@/components/Logo/Logo.vue';
|
||||
import SSOLogin from '@/components/SSOLogin.vue';
|
||||
import type { IFormBoxConfig } from '@/Interface';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import type { EmailOrLdapLoginIdAndPassword } from './SigninView.vue';
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
@@ -19,7 +20,7 @@ withDefaults(
|
||||
|
||||
const emit = defineEmits<{
|
||||
update: [{ name: string; value: string }];
|
||||
submit: [values: { [key: string]: string }];
|
||||
submit: [values: EmailOrLdapLoginIdAndPassword];
|
||||
secondaryClick: [];
|
||||
}>();
|
||||
|
||||
@@ -27,7 +28,7 @@ const onUpdate = (e: { name: string; value: string }) => {
|
||||
emit('update', e);
|
||||
};
|
||||
|
||||
const onSubmit = (values: { [key: string]: string }) => {
|
||||
const onSubmit = (values: EmailOrLdapLoginIdAndPassword) => {
|
||||
emit('submit', values);
|
||||
};
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ describe('SigninView', () => {
|
||||
await userEvent.click(submitButton);
|
||||
|
||||
expect(usersStore.loginWithCreds).toHaveBeenCalledWith({
|
||||
email: 'test@n8n.io',
|
||||
emailOrLdapLoginId: 'test@n8n.io',
|
||||
password: 'password',
|
||||
mfaCode: undefined,
|
||||
mfaRecoveryCode: undefined,
|
||||
|
||||
@@ -15,6 +15,14 @@ import { useCloudPlanStore } from '@/stores/cloudPlan.store';
|
||||
|
||||
import type { IFormBoxConfig } from '@/Interface';
|
||||
import { MFA_AUTHENTICATION_REQUIRED_ERROR_CODE, VIEWS, MFA_FORM } from '@/constants';
|
||||
import type { LoginRequestDto } from '@n8n/api-types';
|
||||
|
||||
export type EmailOrLdapLoginIdAndPassword = Pick<
|
||||
LoginRequestDto,
|
||||
'emailOrLdapLoginId' | 'password'
|
||||
>;
|
||||
|
||||
export type MfaCodeOrMfaRecoveryCode = Pick<LoginRequestDto, 'mfaCode' | 'mfaRecoveryCode'>;
|
||||
|
||||
const usersStore = useUsersStore();
|
||||
const settingsStore = useSettingsStore();
|
||||
@@ -29,7 +37,7 @@ const telemetry = useTelemetry();
|
||||
|
||||
const loading = ref(false);
|
||||
const showMfaView = ref(false);
|
||||
const email = ref('');
|
||||
const emailOrLdapLoginId = ref('');
|
||||
const password = ref('');
|
||||
const reportError = ref(false);
|
||||
|
||||
@@ -50,7 +58,7 @@ const formConfig: IFormBoxConfig = reactive({
|
||||
redirectLink: '/forgot-password',
|
||||
inputs: [
|
||||
{
|
||||
name: 'email',
|
||||
name: 'emailOrLdapLoginId',
|
||||
properties: {
|
||||
label: emailLabel.value,
|
||||
type: 'email',
|
||||
@@ -78,23 +86,16 @@ const formConfig: IFormBoxConfig = reactive({
|
||||
],
|
||||
});
|
||||
|
||||
const onMFASubmitted = async (form: { mfaCode?: string; mfaRecoveryCode?: string }) => {
|
||||
const onMFASubmitted = async (form: MfaCodeOrMfaRecoveryCode) => {
|
||||
await login({
|
||||
email: email.value,
|
||||
emailOrLdapLoginId: emailOrLdapLoginId.value,
|
||||
password: password.value,
|
||||
mfaCode: form.mfaCode,
|
||||
mfaRecoveryCode: form.mfaRecoveryCode,
|
||||
});
|
||||
};
|
||||
|
||||
const isFormWithEmailAndPassword = (values: {
|
||||
[key: string]: string;
|
||||
}): values is { email: string; password: string } => {
|
||||
return 'email' in values && 'password' in values;
|
||||
};
|
||||
|
||||
const onEmailPasswordSubmitted = async (form: { [key: string]: string }) => {
|
||||
if (!isFormWithEmailAndPassword(form)) return;
|
||||
const onEmailPasswordSubmitted = async (form: EmailOrLdapLoginIdAndPassword) => {
|
||||
await login(form);
|
||||
};
|
||||
|
||||
@@ -111,16 +112,11 @@ const getRedirectQueryParameter = () => {
|
||||
return redirect;
|
||||
};
|
||||
|
||||
const login = async (form: {
|
||||
email: string;
|
||||
password: string;
|
||||
mfaCode?: string;
|
||||
mfaRecoveryCode?: string;
|
||||
}) => {
|
||||
const login = async (form: LoginRequestDto) => {
|
||||
try {
|
||||
loading.value = true;
|
||||
await usersStore.loginWithCreds({
|
||||
email: form.email,
|
||||
emailOrLdapLoginId: form.emailOrLdapLoginId,
|
||||
password: form.password,
|
||||
mfaCode: form.mfaCode,
|
||||
mfaRecoveryCode: form.mfaRecoveryCode,
|
||||
@@ -185,8 +181,8 @@ const onFormChanged = (toForm: string) => {
|
||||
reportError.value = false;
|
||||
}
|
||||
};
|
||||
const cacheCredentials = (form: { email: string; password: string }) => {
|
||||
email.value = form.email;
|
||||
const cacheCredentials = (form: EmailOrLdapLoginIdAndPassword) => {
|
||||
emailOrLdapLoginId.value = form.emailOrLdapLoginId;
|
||||
password.value = form.password;
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user