mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 07:03:38 +00:00
fix: handle user not found error
This commit is contained in:
parent
ce09d38972
commit
04d8de7c38
@ -12,7 +12,7 @@ const { getService } = require('../utils');
|
||||
const { validateCreateUserBody, validateUpdateUserBody } = require('./validation/user');
|
||||
|
||||
const { sanitize } = utils;
|
||||
const { ApplicationError, ValidationError } = utils.errors;
|
||||
const { ApplicationError, ValidationError, NotFoundError } = utils.errors;
|
||||
|
||||
const sanitizeOutput = (user, ctx) => {
|
||||
const schema = strapi.getModel('plugin::users-permissions.user');
|
||||
@ -91,6 +91,9 @@ module.exports = {
|
||||
const { email, username, password } = ctx.request.body;
|
||||
|
||||
const user = await getService('user').fetch({ id });
|
||||
if (!user) {
|
||||
throw new NotFoundError(`User with ${id} not existed`);
|
||||
}
|
||||
|
||||
await validateUpdateUserBody(ctx.request.body);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user