📈 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
safeguard against potential sqli (unlikely, because project id's are not user-controlled, but still)
Blue Mousea35a72ce46a6
diff --git a/backend/apps/cloud/src/user/user.controller.ts b/backend/apps/cloud/src/user/user.controller.tsindex 85c99be2d..f1d6aa0c1 100644--- a/backend/apps/cloud/src/user/user.controller.ts+++ b/backend/apps/cloud/src/user/user.controller.ts@@ -406,22 +406,20 @@ export class UserController {try {if (!_isEmpty(user.projects)) {- const pids = _join(- _map(user.projects, el => `'${el.id}'`),- ',',- )+ const pidArray = user.projects.map(el => el.id)const queries = [- `ALTER TABLE analytics DELETE WHERE pid IN (${pids})`,- `ALTER TABLE customEV DELETE WHERE pid IN (${pids})`,- `ALTER TABLE performance DELETE WHERE pid IN (${pids})`,- `ALTER TABLE errors DELETE WHERE pid IN (${pids})`,- `ALTER TABLE error_statuses DELETE WHERE pid IN (${pids})`,- `ALTER TABLE captcha DELETE WHERE pid IN (${pids})`,+ 'ALTER TABLE analytics DELETE WHERE pid IN ({pids:Array(FixedString(12))})',+ 'ALTER TABLE customEV DELETE WHERE pid IN ({pids:Array(FixedString(12))})',+ 'ALTER TABLE performance DELETE WHERE pid IN ({pids:Array(FixedString(12))})',+ 'ALTER TABLE errors DELETE WHERE pid IN ({pids:Array(FixedString(12))})',+ 'ALTER TABLE error_statuses DELETE WHERE pid IN ({pids:Array(FixedString(12))})',+ 'ALTER TABLE captcha DELETE WHERE pid IN ({pids:Array(FixedString(12))})',]await this.projectService.deleteMultiple(user.projects.map(el => el.id))const promises = _map(queries, async query =>clickhouse.command({query,+ query_params: { pids: pidArray },}),)await Promise.all(promises)@@ -435,8 +433,8 @@ export class UserController {},})await this.userService.delete(id)- } catch (e) {- this.logger.error(e)+ } catch (reason) {+ this.logger.error(reason)throw new BadRequestException('accountDeleteError')}diff --git a/backend/apps/community/src/user/user.controller.ts b/backend/apps/community/src/user/user.controller.tsindex 83a962f45..ea99d4f0f 100644--- a/backend/apps/community/src/user/user.controller.ts+++ b/backend/apps/community/src/user/user.controller.ts@@ -172,21 +172,19 @@ export class UserController {try {if (!_isEmpty(projects)) {- const pids = _join(- _map(projects, el => `'${el.id}'`),- ',',- )+ const pidArray = projects.map(el => el.id)const queries = [- `ALTER TABLE analytics DELETE WHERE pid IN (${pids})`,- `ALTER TABLE customEV DELETE WHERE pid IN (${pids})`,- `ALTER TABLE performance DELETE WHERE pid IN (${pids})`,- `ALTER TABLE errors DELETE WHERE pid IN (${pids})`,- `ALTER TABLE error_statuses DELETE WHERE pid IN (${pids})`,+ 'ALTER TABLE analytics DELETE WHERE pid IN ({pids:Array(FixedString(12))})',+ 'ALTER TABLE customEV DELETE WHERE pid IN ({pids:Array(FixedString(12))})',+ 'ALTER TABLE performance DELETE WHERE pid IN ({pids:Array(FixedString(12))})',+ 'ALTER TABLE errors DELETE WHERE pid IN ({pids:Array(FixedString(12))})',+ 'ALTER TABLE error_statuses DELETE WHERE pid IN ({pids:Array(FixedString(12))})',]await deleteProjectsByUserIdClickhouse(id)const promises = _map(queries, async query =>clickhouse.command({query,+ query_params: { pids: pidArray },}),)await Promise.all(promises)