📈 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!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
Fix auth related crashes
Blue Mouseff145db71b92
diff --git a/backend/apps/production/src/alert/alert.controller.ts b/backend/apps/production/src/alert/alert.controller.tsindex be8a6ca7f..6cdf557e6 100644--- a/backend/apps/production/src/alert/alert.controller.ts+++ b/backend/apps/production/src/alert/alert.controller.ts@@ -123,7 +123,9 @@ export class AlertController {)const pids = _map(user.projects, userProject => userProject.id)- const alertsCount = await this.alertService.count({ project: In(pids) })+ const alertsCount = await this.alertService.count({+ where: { project: In(pids) },+ })if (user.planCode === PlanCode.none) {throw new HttpException(diff --git a/backend/apps/production/src/alert/alert.service.ts b/backend/apps/production/src/alert/alert.service.tsindex d49bc34e9..12d6e2837 100644--- a/backend/apps/production/src/alert/alert.service.ts+++ b/backend/apps/production/src/alert/alert.service.ts@@ -1,6 +1,6 @@import { Injectable } from '@nestjs/common'import { InjectRepository } from '@nestjs/typeorm'-import { FindOneOptions, Repository } from 'typeorm'+import { FindManyOptions, FindOneOptions, Repository } from 'typeorm'import { Pagination, PaginationOptionsInterface } from '../common/pagination'import { Alert } from './entity/alert.entity'import { AlertDTO } from './dto/alert.dto'@@ -40,7 +40,7 @@ export class AlertService {})}- async count(options: object = {}): Promise<number> {+ async count(options: FindManyOptions<Alert> = {}): Promise<number> {return this.alertsReporsitory.count(options)}@@ -55,15 +55,12 @@ export class AlertService {return this.alertsReporsitory.find({ where, relations })}- find(params: object): Promise<Alert[]> {- return this.alertsReporsitory.find(params)+ find(options: FindManyOptions<Alert>): Promise<Alert[]> {+ return this.alertsReporsitory.find(options)}- findOneWhere(- where: Record<string, unknown>,- params: object = {},- ): Promise<Alert> {- return this.alertsReporsitory.findOne({ where, ...params })+ findOneWhere(options: FindOneOptions<Alert>): Promise<Alert | null> {+ return this.alertsReporsitory.findOne(options)}async create(alert: AlertDTO | Alert): Promise<Alert> {diff --git a/backend/apps/production/src/analytics/analytics.controller.ts b/backend/apps/production/src/analytics/analytics.controller.tsindex 933d84634..365bb64a3 100644--- a/backend/apps/production/src/analytics/analytics.controller.ts+++ b/backend/apps/production/src/analytics/analytics.controller.ts@@ -320,7 +320,7 @@ export class AnalyticsController {},}- let result: object | void+ let result: any | voidif (isCaptcha) {result = await this.analyticsService.groupCaptchaByTimeBucket(diff --git a/backend/apps/production/src/auth/auth.controller.ts b/backend/apps/production/src/auth/auth.controller.tsindex bc6449c86..348e71002 100644--- a/backend/apps/production/src/auth/auth.controller.ts+++ b/backend/apps/production/src/auth/auth.controller.ts@@ -155,13 +155,16 @@ export class AuthController {await this.authService.sendTelegramNotification(user.id, headers, ip)+ console.log('before:', user)if (user.isTwoFactorAuthenticationEnabled) {// @ts-expect-erroruser = _pick(user, ['isTwoFactorAuthenticationEnabled', 'email'])} else {- user = await this.authService.getSharedProjectsForUser(user as User)+ user = await this.authService.getSharedProjectsForUser(user)}+ console.log('after:', user)+return {...jwtTokens,user: this.userService.omitSensitiveData(user as User),diff --git a/backend/apps/production/src/auth/auth.service.ts b/backend/apps/production/src/auth/auth.service.tsindex 5e9091f61..1385c7f60 100644--- a/backend/apps/production/src/auth/auth.service.ts+++ b/backend/apps/production/src/auth/auth.service.ts@@ -204,7 +204,7 @@ export class AuthService {public async getSharedProjectsForUser(user: User): Promise<User> {const sharedProjects = await this.projectService.findShare({where: {- user: user.id,+ user: { id: user.id },},relations: ['project'],})diff --git a/backend/apps/production/src/marketplace/extensions/extensions.service.ts b/backend/apps/production/src/marketplace/extensions/extensions.service.tsindex d4efb66d2..e88392fc5 100644--- a/backend/apps/production/src/marketplace/extensions/extensions.service.ts+++ b/backend/apps/production/src/marketplace/extensions/extensions.service.ts@@ -103,7 +103,7 @@ export class ExtensionsService {await this.extensionToUserRepository.delete({ extensionId, userId })}- filterOwner(owner: User): object {+ filterOwner(owner: User) {return _pick(owner, ['nickname'])}diff --git a/backend/apps/production/src/project/project.service.ts b/backend/apps/production/src/project/project.service.tsindex d17d8df2d..89ea1a402 100644--- a/backend/apps/production/src/project/project.service.ts+++ b/backend/apps/production/src/project/project.service.ts@@ -9,7 +9,12 @@ import {NotFoundException,} from '@nestjs/common'import { InjectRepository } from '@nestjs/typeorm'-import { FindOneOptions, FindOptionsWhere, Repository } from 'typeorm'+import {+ FindManyOptions,+ FindOneOptions,+ FindOptionsWhere,+ Repository,+} from 'typeorm'import { customAlphabet } from 'nanoid'import handlebars from 'handlebars'import puppeteer from 'puppeteer'@@ -457,8 +462,10 @@ export class ProjectService {return this.projectShareRepository.update(id, share)}- async findShare(params: object): Promise<ProjectShare[]> {- return this.projectShareRepository.find(params)+ async findShare(+ options: FindManyOptions<ProjectShare>,+ ): Promise<ProjectShare[]> {+ return this.projectShareRepository.find(options)}async findOneShare(@@ -467,32 +474,29 @@ export class ProjectService {return this.projectShareRepository.findOne(options)}- findOneWithRelations(- id: string,- relations = ['admin'],- ): Promise<Project | null> {+ findOneWithRelations(id: string, relations = ['admin']) {return this.projectsRepository.findOne({ where: { id }, relations })}- findOne(options: FindOneOptions<Project>): Promise<Project | null> {+ findOne(options: FindOneOptions<Project>) {return this.projectsRepository.findOne(options)}findWhere(where: Record<string, unknown> | Record<string, unknown>[],relations?: string[],- ): Promise<Project[]> {+ ) {return this.projectsRepository.find({ where, relations })}- find(params: object): Promise<Project[]> {- return this.projectsRepository.find(params)+ find(options: FindManyOptions<Project>) {+ return this.projectsRepository.find(options)}findOneWhere(where: Record<string, unknown>,options: Omit<FindOneOptions<Project>, 'where'> = {},- ): Promise<Project> {+ ) {return this.projectsRepository.findOne({ where, ...options })}@@ -696,7 +700,7 @@ export class ProjectService {const projects = await this.find({where: {- admin: uid,+ admin: { id: uid },},select: ['id'],})@@ -795,7 +799,7 @@ export class ProjectService {const projects = await this.find({where: {- admin: uid,+ admin: { id: uid },},select: ['id'],})diff --git a/backend/apps/production/src/user/user.controller.ts b/backend/apps/production/src/user/user.controller.tsindex cc124cd83..fb9504184 100644--- a/backend/apps/production/src/user/user.controller.ts+++ b/backend/apps/production/src/user/user.controller.ts@@ -100,17 +100,19 @@ export class UserController {@Get('/me')@UseGuards(RolesGuard)@Roles(UserType.CUSTOMER, UserType.ADMIN)- async me(@CurrentUserId() user_id: string): Promise<Partial<User>> {- this.logger.log({ user_id }, 'GET /user/me')+ async me(@CurrentUserId() uid: string): Promise<Partial<User>> {+ this.logger.log({ uid }, 'GET /user/me')const sharedProjects = await this.projectService.findShare({where: {- user: user_id,+ user: {+ id: uid,+ },},relations: ['project'],})const user = this.userService.omitSensitiveData(- await this.userService.findOne({ where: { id: user_id } }),+ await this.userService.findOne({ where: { id: uid } }),)user.sharedProjects = sharedProjectsdiff --git a/backend/apps/selfhosted/src/project/project.service.ts b/backend/apps/selfhosted/src/project/project.service.tsindex 9af7e06f6..e7b636194 100644--- a/backend/apps/selfhosted/src/project/project.service.ts+++ b/backend/apps/selfhosted/src/project/project.service.ts@@ -270,7 +270,7 @@ export class ProjectService {)}- formatToClickhouse(project: any): object {+ formatToClickhouse(project: any) {const updProject = { ...project }updProject.active = Number(updProject.active)updProject.public = Number(updProject.public)