diff --git a/backend/src/v1/users/users.controller.ts b/backend/src/v1/users/users.controller.ts index b7aec194..64b79250 100644 --- a/backend/src/v1/users/users.controller.ts +++ b/backend/src/v1/users/users.controller.ts @@ -76,8 +76,8 @@ export const create = async (req: Request, res: Response, next: NextFunction) => if (!pwSchema.validate(String(password))) { return next(new ErrorResponse(errorCode.INVALIDATE_PASSWORD, status.BAD_REQUEST)); } - await usersService.createUser(String(email), await bcrypt.hash(String(password), 10)); - return res.status(status.OK).send(`${email} created!`); + const result = await usersService.createUser(String(email), await bcrypt.hash(String(password), 10)); + return res.status(status.OK).send(`${result.email} created!`); } catch (error: any) { const errorNumber = parseInt(error.message, 10); if (errorNumber >= 200 && errorNumber < 300) { diff --git a/backend/src/v1/users/users.repository.ts b/backend/src/v1/users/users.repository.ts index a210982d..0c187f2b 100644 --- a/backend/src/v1/users/users.repository.ts +++ b/backend/src/v1/users/users.repository.ts @@ -9,6 +9,7 @@ import { UserReservation, User, } from '~/entity/entities'; +import { InsertResult } from "kysely"; import * as models from '../DTO/users.model'; export default class UsersRepository extends Repository { @@ -111,11 +112,12 @@ export default class UsersRepository extends Repository { async insertUser(email: string, password: string) { const penaltyEndDate = new Date(0); penaltyEndDate.setDate(penaltyEndDate.getDate() - 1); - await this.insert({ + const result = await this.save({ email, password, penaltyEndDate: formatDate(penaltyEndDate), }); + return result; } async updateUser(id: number, values: {}): Promise { diff --git a/backend/src/v1/users/users.service.ts b/backend/src/v1/users/users.service.ts index ee4bdba6..1a2588a8 100644 --- a/backend/src/v1/users/users.service.ts +++ b/backend/src/v1/users/users.service.ts @@ -98,8 +98,8 @@ export default class UsersService { if (emailCount > 0) { throw new Error(errorCode.EMAIL_OVERLAP); } - await this.usersRepository.insertUser(email, password); - return null; + const result = await this.usersRepository.insertUser(email, password); + return result; } async updateUserEmail(id: number, email: string) {