📈 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 broken auth flow because the tokens were read differently
Blue Mouse50bbf1996263
diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.tsindex ffa86384a..d424dd874 100644--- a/src/auth/auth.service.ts+++ b/src/auth/auth.service.ts@@ -48,6 +48,7 @@ import {isSelfhosted,SELFHOSTED_EMAIL,SELFHOSTED_PASSWORD,+ JWT_ACCESS_TOKEN_SECRET,} from 'src/common/constants'import { TelegramService } from 'src/integrations/telegram/telegram.service'import { SSOProviders } from './dtos/sso-generate.dto'@@ -179,7 +180,7 @@ export class AuthService {{algorithm: 'HS256',expiresIn: 60 * 30,- secret: this.configService.get('JWT_ACCESS_TOKEN_SECRET'),+ secret: JWT_ACCESS_TOKEN_SECRET,},)}diff --git a/src/auth/guards/roles.guard.ts b/src/auth/guards/roles.guard.tsindex 421c027f7..cf75d1045 100644--- a/src/auth/guards/roles.guard.ts+++ b/src/auth/guards/roles.guard.ts@@ -5,11 +5,9 @@ import { verify } from 'jsonwebtoken'import { UserType, generateSelfhostedUser } from 'src/user/entities/user.entity'import { UserService } from 'src/user/user.service'-import { isSelfhosted } from 'src/common/constants'+import { isSelfhosted, JWT_ACCESS_TOKEN_SECRET } from 'src/common/constants'import { IS_TWO_FA_NOT_REQUIRED_KEY, ROLES_KEY } from '../decorators'-const ACCESS_TOKEN_SECRET = process.env.JWT_ACCESS_TOKEN_SECRET-@Injectable()export class RolesGuard implements CanActivate {constructor(@@ -59,7 +57,7 @@ export class RolesGuard implements CanActivate {if (isSelfhosted) {try {- const decoded: any = verify(token, ACCESS_TOKEN_SECRET)+ const decoded: any = verify(token, JWT_ACCESS_TOKEN_SECRET)// If the token is not decoded, it means it's invalidif (!decoded) {@@ -77,7 +75,7 @@ export class RolesGuard implements CanActivate {}try {- const decoded: any = verify(token, ACCESS_TOKEN_SECRET)+ const decoded: any = verify(token, JWT_ACCESS_TOKEN_SECRET)// If the token is not decoded, it means it's invalidif (!decoded) {diff --git a/src/auth/strategies/jwt-access-token.strategy.ts b/src/auth/strategies/jwt-access-token.strategy.tsindex 45a621187..947719f68 100644--- a/src/auth/strategies/jwt-access-token.strategy.ts+++ b/src/auth/strategies/jwt-access-token.strategy.ts@@ -3,7 +3,7 @@ import { ConfigService } from '@nestjs/config'import { PassportStrategy } from '@nestjs/passport'import { Strategy, ExtractJwt } from 'passport-jwt'-import { isSelfhosted, SELFHOSTED_UUID } from 'src/common/constants'+import { isSelfhosted, SELFHOSTED_UUID, JWT_ACCESS_TOKEN_SECRET } from 'src/common/constants'import { generateSelfhostedUser } from 'src/user/entities/user.entity'import { UserService } from 'src/user/user.service'import { IJwtPayload } from '../interfaces'@@ -20,7 +20,7 @@ export class JwtAccessTokenStrategy extends PassportStrategy(super({jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),ignoreExpiration: false,- secretOrKey: configService.get('JWT_ACCESS_TOKEN_SECRET'),+ secretOrKey: JWT_ACCESS_TOKEN_SECRET,})}diff --git a/src/common/constants.ts b/src/common/constants.tsindex f3ff32107..d09a9f2d3 100644--- a/src/common/constants.ts+++ b/src/common/constants.ts@@ -44,6 +44,7 @@ const clickhouse = new ClickHouse({},})+const { JWT_ACCESS_TOKEN_SECRET } = process.envconst isSelfhosted = Boolean(process.env.SELFHOSTED)const isTgTokenPresent = Boolean(process.env.TG_BOT_TOKEN)const isNewRelicEnabled = Boolean(process.env.USE_NEW_RELIC)@@ -158,4 +159,5 @@ export {isTgTokenPresent,DEFAULT_SELFHOSTED_UUID,REDIS_SSO_UUID,+ JWT_ACCESS_TOKEN_SECRET,}