forked from wangziqi/gongxue-base
移除账号启用状态统一使用归档
This commit is contained in:
@@ -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' }));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user