移除账号启用状态统一使用归档

This commit is contained in:
2026-07-24 09:53:04 +08:00
parent a9c6578569
commit 13ef357448
13 changed files with 86 additions and 67 deletions

View File

@@ -47,4 +47,28 @@ describe('AuthService — authentication boundaries', () => {
).rejects.toThrow('账号已失效');
expect(userRepo.save).not.toHaveBeenCalled();
});
it('allows a legacy disabled user because archive is the only account status', async () => {
const userRepo = {
findOne: jest.fn().mockResolvedValue({
id: 3,
username: 'legacy-disabled',
name: '旧账号',
passwordHash: await bcrypt.hash('secret', 4),
isActive: false,
isArchived: false,
roles: [],
}),
save: jest.fn(),
};
const service = new AuthService(
userRepo as never,
{ sign: jest.fn().mockReturnValue('token') } as never,
{ getUserPermissions: jest.fn().mockResolvedValue([]) } as never,
);
await expect(
service.login({ username: 'legacy-disabled', password: 'secret' }, '192.0.2.11'),
).resolves.toEqual(expect.objectContaining({ access_token: 'token' }));
});
});