diff --git a/src/repositories/userRepository.ts b/src/repositories/userRepository.ts index 57ac0cdbf..31f2233d6 100644 --- a/src/repositories/userRepository.ts +++ b/src/repositories/userRepository.ts @@ -36,7 +36,6 @@ export const isFirstTimeDonor = async (userId: number): Promise => { export const findUserByWalletAddress = async ( walletAddress: string, includeSensitiveFields = true, - ownerUserId?: number, ): Promise => { const query = User.createQueryBuilder('user').where( `LOWER("walletAddress") = :walletAddress`, @@ -52,7 +51,7 @@ export const findUserByWalletAddress = async ( user.projectsCount = await fetchUserProjectsCount( user!.id, - Number(user?.id) === Number(ownerUserId), + includeSensitiveFields, ); return user; @@ -60,14 +59,14 @@ export const findUserByWalletAddress = async ( export const fetchUserProjectsCount = async ( userId: number, - ownerViewing: boolean, + includeSensitiveFields: boolean, ) => { const projectsCount = Project.createQueryBuilder('project').where( 'project."adminUserId" = :id', { id: userId }, ); - if (!ownerViewing) { + if (!includeSensitiveFields) { projectsCount.andWhere( `project.statusId = ${ProjStatus.active} AND project.reviewStatus = :reviewStatus`, { reviewStatus: ReviewStatus.Listed }, diff --git a/src/resolvers/userResolver.ts b/src/resolvers/userResolver.ts index 7a9f9d38f..109655e75 100644 --- a/src/resolvers/userResolver.ts +++ b/src/resolvers/userResolver.ts @@ -66,7 +66,6 @@ export class UserResolver { const foundUser = await findUserByWalletAddress( address, includeSensitiveFields, - user?.userId, ); return { isSignedIn: Boolean(user), @@ -84,7 +83,6 @@ export class UserResolver { const foundUser = await findUserByWalletAddress( address, includeSensitiveFields, - user?.userId, ); if (!foundUser) return;