📈 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
better security
Blue Mouse1d3353f76a13
diff --git a/backend/apps/cloud/src/project/gsc.controller.ts b/backend/apps/cloud/src/project/gsc.controller.tsindex 1bc5f70b6..7279755d3 100644--- a/backend/apps/cloud/src/project/gsc.controller.ts+++ b/backend/apps/cloud/src/project/gsc.controller.ts@@ -27,12 +27,16 @@ export class GSCController {) {}@Post('process-token')- async processGSCToken(@Body() body: { code: string; state: string }) {+ @Auth()+ async processGSCToken(+ @Body() body: { code: string; state: string },+ @CurrentUserId() uid: string,+ ) {const { code, state } = bodyif (!code || !state) {throw new BadRequestException('Invalid GSC token parameters')}- const { pid } = await this.gscService.handleOAuthCallback(code, state)+ const { pid } = await this.gscService.handleOAuthCallback(uid, code, state)return { pid }}diff --git a/backend/apps/cloud/src/project/gsc.service.ts b/backend/apps/cloud/src/project/gsc.service.tsindex 3288445e1..2cf3111ff 100644--- a/backend/apps/cloud/src/project/gsc.service.ts+++ b/backend/apps/cloud/src/project/gsc.service.ts@@ -52,6 +52,9 @@ export class GSCService {}async generateConnectURL(uid: string, pid: string): Promise<{ url: string }> {+ const project = await this.projectService.getRedisProject(pid)+ this.projectService.allowedToManage(project, uid)+const oauth2Client = this.getOAuthClient()const state = `${pid}:${uid}:${Date.now()}`@@ -75,7 +78,7 @@ export class GSCService {return { url }}- async handleOAuthCallback(code: string, state: string) {+ async handleOAuthCallback(uid: string, code: string, state: string) {const cached = await redis.get(REDIS_STATE_PREFIX + state)if (!cached) {throw new BadRequestException('Invalid or expired OAuth state')@@ -83,6 +86,10 @@ export class GSCService {const { pid } = JSON.parse(cached)+ const project = await this.projectService.getRedisProject(pid)++ this.projectService.allowedToManage(project, uid)+const oauth2Client = this.getOAuthClient()const { tokens } = await oauth2Client.getToken(code)oauth2Client.setCredentials(tokens)