📈 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
fixed auth/me for selfhosted
Blue Mouse64e4d71e47fa
diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.tsindex 86c238607..3ae9824b0 100644--- a/src/auth/auth.controller.ts+++ b/src/auth/auth.controller.ts@@ -1,7 +1,7 @@import {Controller, Post, Body, Req, Get, Param, BadRequestException, UseGuards, Ip, Headers, UnprocessableEntityException,} from '@nestjs/common'-import { Request } from 'express'+import e, { Request } from 'express'import { ApiTags } from '@nestjs/swagger'import { AuthService } from './auth.service'@@ -22,7 +22,7 @@ import { LetterTemplate } from '../mailer/letter'import { AppLoggerService } from '../logger/logger.service'import { SelfhostedGuard } from '../common/guards/selfhosted.guard'import {- isSelfhosted, SELFHOSTED_EMAIL, SELFHOSTED_PASSWORD,+ isSelfhosted, SELFHOSTED_EMAIL, SELFHOSTED_PASSWORD, SELFHOSTED_UUID,} from 'src/common/constants'// TODO: Add logout endpoint to invalidate the token@@ -42,9 +42,17 @@ export class AuthController {@Roles(UserType.CUSTOMER, UserType.ADMIN)async me(@CurrentUserId() user_id: string): Promise<User> {this.logger.log({ user_id }, 'GET /auth/me')+ let user- const user = await this.userService.findOneWhere({ id: user_id })- delete user.password+ if (isSelfhosted) {+ user = {+ id: SELFHOSTED_UUID,+ email: SELFHOSTED_EMAIL,+ }+ } else {+ user = await this.userService.findOneWhere({ id: user_id })+ delete user.password+ }return user}diff --git a/src/common/constants.ts b/src/common/constants.tsindex 2415ca2f3..a1962dbc0 100644--- a/src/common/constants.ts+++ b/src/common/constants.ts@@ -88,9 +88,7 @@ const initialiseClickhouse = async () => {const initialiseSelfhosted = () => {if (isSelfhosted) {- fs.writeFile('../../projects.json', '{}', { flag: 'wx' }, (err) => {- if (err) console.error(err)- })+ fs.writeFile('../../projects.json', '{}', { flag: 'wx' }, () => {})}}diff --git a/src/project/project.controller.ts b/src/project/project.controller.tsindex c830fb8c7..af7646772 100644--- a/src/project/project.controller.ts+++ b/src/project/project.controller.ts@@ -86,7 +86,7 @@ export class ProjectController {projects[project.id] = projecttry {- await fs.writeFile('../../projects.json', JSON.stringify(projects), { flag: 'w' })+ await fs.writeFile('../../projects.json', JSON.stringify(projects))} catch (e) {throw new InternalServerErrorException('Error while saving project')}@@ -161,7 +161,7 @@ export class ProjectController {projects[project.id] = projecttry {- await fs.writeFile('../../projects.json', JSON.stringify(projects), { flag: 'w' })+ await fs.writeFile('../../projects.json', JSON.stringify(projects))} catch (e) {throw new InternalServerErrorException('Error while saving project')}@@ -216,7 +216,7 @@ export class ProjectController {}delete projects[id]try {- await fs.writeFile('../../projects.json', JSON.stringify(projects), { flag: 'w' })+ await fs.writeFile('../../projects.json', JSON.stringify(projects))} catch (e) {throw new InternalServerErrorException('Error while saving project')}