0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

refactor(core): remove SIE identifier check from user management API

This commit is contained in:
Charles Zhao 2022-11-10 15:41:43 +08:00
parent 81aa4cd8ed
commit 33b5e2e6b0
No known key found for this signature in database
GPG key ID: 4858774754C92DF2
2 changed files with 1 additions and 60 deletions

View file

@ -251,64 +251,6 @@ describe('adminUserRoutes', () => {
expect(updateUserById).not.toBeCalled();
});
it('PATCH /users/:userId should throw if required sign-up identifier username is missing', async () => {
mockFindDefaultSignInExperience.mockImplementationOnce(async () => ({
signUp: {
identifier: SignUpIdentifier.Username,
password: false,
verify: false,
},
}));
await expect(
userRequest
.patch('/users/foo')
.send({ primaryEmail: 'test@abc.com', primaryPhone: '18688886666' })
).resolves.toHaveProperty('status', 422);
});
it('PATCH /users/:userId should throw if required sign-up identifier email is missing', async () => {
mockFindDefaultSignInExperience.mockImplementationOnce(async () => ({
signUp: {
identifier: SignUpIdentifier.Email,
password: false,
verify: false,
},
}));
await expect(
userRequest.patch('/users/foo').send({ username: 'test', primaryPhone: '18688886666' })
).resolves.toHaveProperty('status', 422);
});
it('PATCH /users/:userId should throw if required sign-up identifier phone is missing', async () => {
mockFindDefaultSignInExperience.mockImplementationOnce(async () => ({
signUp: {
identifier: SignUpIdentifier.Sms,
password: false,
verify: false,
},
}));
await expect(
userRequest.patch('/users/foo').send({ username: 'test', primaryEmail: 'test@abc.com' })
).resolves.toHaveProperty('status', 422);
});
it('PATCH /users/:userId should throw if required sign-up identifiers email and phone are both missing', async () => {
mockFindDefaultSignInExperience.mockImplementationOnce(async () => ({
signUp: {
identifier: SignUpIdentifier.EmailOrSms,
password: false,
verify: false,
},
}));
await expect(
userRequest.patch('/users/foo').send({ username: 'test' })
).resolves.toHaveProperty('status', 422);
});
it('PATCH /users/:userId should throw if new username is already in use', async () => {
mockHasUser.mockImplementationOnce(async () => true);

View file

@ -21,7 +21,7 @@ import {
} from '@/queries/user';
import assertThat from '@/utils/assert-that';
import { checkExistingSignUpIdentifiers, checkRequiredSignUpIdentifiers } from './session/utils';
import { checkExistingSignUpIdentifiers } from './session/utils';
import type { AuthedRouter } from './types';
export default function adminUserRoutes<T extends AuthedRouter>(router: T) {
@ -175,7 +175,6 @@ export default function adminUserRoutes<T extends AuthedRouter>(router: T) {
} = ctx.guard;
await findUserById(userId);
await checkRequiredSignUpIdentifiers(body);
await checkExistingSignUpIdentifiers(body);
// Temp solution to validate the existence of input roleNames