diff --git a/apps/api/src/modules/auth/auth.employee.service.edge.test.ts b/apps/api/src/modules/auth/auth.employee.service.edge.test.ts index 0cda582..6f6ec4f 100644 --- a/apps/api/src/modules/auth/auth.employee.service.edge.test.ts +++ b/apps/api/src/modules/auth/auth.employee.service.edge.test.ts @@ -32,6 +32,7 @@ const employee = { preferredLanguage: 'fr', companyId: 'company_1', isActive: true, + emailVerified: true, passwordHash: 'hash_old', company: { name: 'Atlas Cars', slug: 'atlas' }, } @@ -73,6 +74,15 @@ describe('auth.employee.service edge behavior', () => { }) }) + it('rejects login for employees whose email has not been verified', async () => { + vi.mocked(repo.findEmployeeWithCompanyByEmail).mockResolvedValue({ ...employee, emailVerified: false } as never) + + await expect(service.login({ email: 'agent@example.test', password: 'correct-password' })).rejects.toMatchObject({ + statusCode: 401, + error: 'email_not_verified', + }) + }) + it('distinguishes employees without passwords from wrong credentials', async () => { vi.mocked(repo.findEmployeeWithCompanyByEmail).mockResolvedValue({ ...employee, passwordHash: null } as never)