0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-06 20:40:08 -05:00

fix(core): update role names (#913)

This commit is contained in:
Xiao Yijun 2022-05-20 17:59:55 +08:00 committed by GitHub
parent 5e0c39e516
commit d65999514f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View file

@ -237,6 +237,17 @@ describe('adminUserRoutes', () => {
expect(updateUserById).not.toHaveBeenCalled();
});
it('PATCH /users/:userId should update if roleNames field is an empty array', async () => {
const roleNames: string[] = [];
const response = await userRequest.patch('/users/foo').send({ roleNames });
expect(response.status).toEqual(200);
expect(response.body).toEqual({
...mockUserResponse,
roleNames,
});
});
it('PATCH /users/:userId/password', async () => {
const mockedUserId = 'foo';
const password = '123456';

View file

@ -130,7 +130,7 @@ export default function adminUserRoutes<T extends AuthedRouter>(router: T) {
}
// Temp solution to validate the existence of input roleNames
if (body.roleNames) {
if (body.roleNames?.length) {
const { roleNames } = body;
const roles = await findRolesByRoleNames(roleNames);