feat(core): Invalidate all sessions when MFA is enabled/disabled (#15524)

This commit is contained in:
Ricardo Espinoza
2025-05-21 02:59:22 -04:00
committed by GitHub
parent a1a33deee5
commit 2a35c19ef9
18 changed files with 92 additions and 76 deletions

View File

@@ -1,5 +1,4 @@
import type { User } from '@n8n/db';
import { AuthUserRepository } from '@n8n/db';
import { UserRepository, type User } from '@n8n/db';
import { Container } from '@n8n/di';
import { randomString } from 'n8n-workflow';
@@ -130,7 +129,7 @@ describe('Enable MFA setup', () => {
await testServer.authAgentFor(owner).post('/mfa/verify').send({ mfaCode }).expect(200);
await testServer.authAgentFor(owner).post('/mfa/enable').send({ mfaCode }).expect(200);
const user = await Container.get(AuthUserRepository).findOneOrFail({
const user = await Container.get(UserRepository).findOneOrFail({
where: {},
});
@@ -153,7 +152,7 @@ describe('Enable MFA setup', () => {
await testServer.authAgentFor(owner).post('/mfa/enable').send({ mfaCode }).expect(400);
const user = await Container.get(AuthUserRepository).findOneOrFail({
const user = await Container.get(UserRepository).findOneOrFail({
where: {},
});
@@ -175,7 +174,7 @@ describe('Disable MFA setup', () => {
})
.expect(200);
const dbUser = await Container.get(AuthUserRepository).findOneOrFail({
const dbUser = await Container.get(UserRepository).findOneOrFail({
where: { id: user.id },
});
@@ -396,7 +395,7 @@ describe('Login', () => {
const data = response.body.data;
expect(data.mfaEnabled).toBe(true);
const dbUser = await Container.get(AuthUserRepository).findOneOrFail({
const dbUser = await Container.get(UserRepository).findOneOrFail({
where: { id: user.id },
});