fix(core): Do not validate email when LDAP is enabled (#13605)

This commit is contained in:
Ricardo Espinoza
2025-03-03 19:15:52 +01:00
committed by GitHub
parent 24681f843c
commit 17738c5096
16 changed files with 187 additions and 83 deletions

View File

@@ -43,7 +43,7 @@ describe('POST /login', () => {
test('should log user in', async () => {
const response = await testServer.authlessAgent.post('/login').send({
email: owner.email,
emailOrLdapLoginId: owner.email,
password: ownerPassword,
});
@@ -87,7 +87,7 @@ describe('POST /login', () => {
await mfaService.enableMfa(owner.id);
const response = await testServer.authlessAgent.post('/login').send({
email: owner.email,
emailOrLdapLoginId: owner.email,
password: ownerPassword,
mfaCode: mfaService.totp.generateTOTP(secret),
});
@@ -131,7 +131,7 @@ describe('POST /login', () => {
});
const response = await testServer.authlessAgent.post('/login').send({
email: member.email,
emailOrLdapLoginId: member.email,
password,
});
expect(response.statusCode).toBe(403);
@@ -148,19 +148,16 @@ describe('POST /login', () => {
expect(response.statusCode).toBe(200);
});
test('should fail on invalid email in the payload', async () => {
test('should fail with invalid email in the payload is the current authentication method is "email"', async () => {
config.set('userManagement.authenticationMethod', 'email');
const response = await testServer.authlessAgent.post('/login').send({
email: 'invalid-email',
emailOrLdapLoginId: 'invalid-email',
password: ownerPassword,
});
expect(response.statusCode).toBe(400);
expect(response.body).toEqual({
validation: 'email',
code: 'invalid_string',
message: 'Invalid email',
path: ['email'],
});
expect(response.body.message).toBe('Invalid email address');
});
});