Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

remove processUser in favour of omitSensitiveData

Blue Moused344896b7d92
diff --git a/apps/production/src/user/user.controller.ts b/apps/production/src/user/user.controller.ts
index abaf11d84..a75bae9a5 100644
--- a/apps/production/src/user/user.controller.ts
+++ b/apps/production/src/user/user.controller.ts
@@ -103,13 +103,13 @@ export class UserController {
},
relations: ['project'],
})
- const user = this.userService.processUser(
+ const user = this.userService.omitSensitiveData(
await this.userService.findOneWhere({ id: user_id }),
)
user.sharedProjects = sharedProjects
- return this.userService.omitSensitiveData(user)
+ return user
}
@Get('/')
diff --git a/apps/production/src/user/user.service.ts b/apps/production/src/user/user.service.ts
index e0bdacdee..fdd7268e3 100644
--- a/apps/production/src/user/user.service.ts
+++ b/apps/production/src/user/user.service.ts
@@ -144,7 +144,14 @@ export class UserService {
}
omitSensitiveData(user: Partial<User>): Partial<User> {
- return _omit(user, [
+ const maxEventsCount = ACCOUNT_PLANS[user?.planCode]?.monthlyUsageLimit || 0
+
+ const enhancedUser = {
+ ...user,
+ maxEventsCount,
+ }
+
+ return _omit(enhancedUser, [
'password',
'twoFactorRecoveryCode',
'twoFactorAuthenticationSecret',
@@ -213,21 +220,6 @@ export class UserService {
}
}
- processUser(user: User): Partial<User> {
- // @ts-ignore
- const maxEventsCount = ACCOUNT_PLANS[user?.planCode]?.monthlyUsageLimit || 0
- const userData = {
- // @ts-ignore
- ...user,
- password: undefined,
- twoFactorRecoveryCode: undefined,
- twoFactorAuthenticationSecret: undefined,
- maxEventsCount,
- }
-
- return userData
- }
-
search(query: string): Promise<User[]> {
return this.usersRepository
.createQueryBuilder('user')