From d5f4f15a90cb2cf08619ec19a69f4032787c72f3 Mon Sep 17 00:00:00 2001 From: JKaypa Date: Mon, 19 Aug 2024 15:30:14 -0500 Subject: [PATCH] OV-2: * edit findByEmail methods --- backend/src/bundles/auth/auth.service.ts | 2 +- backend/src/bundles/users/user.repository.ts | 11 ++++++----- backend/src/bundles/users/user.service.ts | 8 ++++++-- backend/src/common/types/repository.type.ts | 3 ++- backend/src/common/types/service.type.ts | 3 ++- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/backend/src/bundles/auth/auth.service.ts b/backend/src/bundles/auth/auth.service.ts index c7a34fc24..fabf0d934 100644 --- a/backend/src/bundles/auth/auth.service.ts +++ b/backend/src/bundles/auth/auth.service.ts @@ -23,7 +23,7 @@ class AuthService { userRequestDto: UserSignInRequestDto, ): Promise { const { email, password } = userRequestDto; - const user = await this.userService.find(email); + const user = await this.userService.findByEmail(email); if (!user) { throw new HttpError({ diff --git a/backend/src/bundles/users/user.repository.ts b/backend/src/bundles/users/user.repository.ts index 9bbd2d3a9..b4d6110d8 100644 --- a/backend/src/bundles/users/user.repository.ts +++ b/backend/src/bundles/users/user.repository.ts @@ -9,11 +9,12 @@ class UserRepository implements Repository { this.userModel = userModel; } - public async find(payload: string | number): Promise { - const user = await this.userModel - .query() - .findOne({ payload }) - .execute(); + public find(): ReturnType { + return Promise.resolve(null); + } + + public async findByEmail(email: string): Promise { + const user = await this.userModel.query().findOne({ email }).execute(); return user ? UserEntity.initialize(user) : null; } diff --git a/backend/src/bundles/users/user.service.ts b/backend/src/bundles/users/user.service.ts index 00c796c2e..778c8f95f 100644 --- a/backend/src/bundles/users/user.service.ts +++ b/backend/src/bundles/users/user.service.ts @@ -16,8 +16,12 @@ class UserService implements Service { this.userRepository = userRepository; } - public async find(payload: string | number): Promise { - return await this.userRepository.find(payload); + public find(): ReturnType { + return Promise.resolve(null); + } + + public async findByEmail(email: string): Promise { + return await this.userRepository.findByEmail(email); } public async findAll(): Promise { diff --git a/backend/src/common/types/repository.type.ts b/backend/src/common/types/repository.type.ts index 21b21ed88..4008a9251 100644 --- a/backend/src/common/types/repository.type.ts +++ b/backend/src/common/types/repository.type.ts @@ -1,6 +1,7 @@ type Repository = { - find(payload: string | number): Promise; + find(): Promise; findAll(): Promise; + findByEmail(email: string): Promise; create(payload: unknown): Promise; update(): Promise; delete(): Promise; diff --git a/backend/src/common/types/service.type.ts b/backend/src/common/types/service.type.ts index 31d498842..245943234 100644 --- a/backend/src/common/types/service.type.ts +++ b/backend/src/common/types/service.type.ts @@ -1,8 +1,9 @@ type Service = { - find(payload: string | number): Promise; + find(): Promise; findAll(): Promise<{ items: T[]; }>; + findByEmail(email: string): Promise; create(payload: unknown): Promise; update(): Promise; delete(): Promise;