diff --git a/src/controllers/users.controller.ts b/src/controllers/users.controller.ts index f5096c4..39d7e4f 100644 --- a/src/controllers/users.controller.ts +++ b/src/controllers/users.controller.ts @@ -67,6 +67,11 @@ export class UsersController extends BaseController { } async create(req: Request, res: Response, next: NextFunction) { + if (req.body.password !== req.body.repeatPassword) { + next(new HttpError(400, 'Bad Request', 'Passwords do not match')); + return; + } + if (!req.body.password || typeof req.body.password !== 'string') { next( new HttpError( diff --git a/src/repositories/users.sql.repo.ts b/src/repositories/users.sql.repo.ts index 075c3bd..5196f11 100644 --- a/src/repositories/users.sql.repo.ts +++ b/src/repositories/users.sql.repo.ts @@ -78,10 +78,6 @@ export class UsersSqlRepo implements WithLoginRepo { } async create(data: UserCreateDto): Promise { - if (data.password !== data.repeatPassword) { - throw new HttpError(400, 'Bad Request', 'Passwords do not match'); - } - try { const newUser = await this.prisma.user.create({ data, select }); return newUser as User; diff --git a/src/routers/files.router.ts b/src/routers/files.router.ts index 5d384d5..2dc61d3 100644 --- a/src/routers/files.router.ts +++ b/src/routers/files.router.ts @@ -15,7 +15,7 @@ export class FilesRouter { this.router.post( '/', - interceptor.singleFile('avatar').bind(interceptor), + interceptor.singleFile('avatar'), interceptor.upload.bind(interceptor), controller.fileHandler.bind(controller) ); diff --git a/src/routers/users.router.ts b/src/routers/users.router.ts index 855ec5f..c20948c 100644 --- a/src/routers/users.router.ts +++ b/src/routers/users.router.ts @@ -19,7 +19,7 @@ export class UsersRouter { this.router.post( '/signup', filesInterceptor.singleFile('avatar'), - filesInterceptor.upload.bind(filesInterceptor), + controller.create.bind(controller) ); this.router.post('/login', controller.login.bind(controller));