📈 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: optional auth
Blue Mousec3ca506301c2
diff --git a/backend/apps/cloud/src/auth/guards/jwt-access-token.guard.ts b/backend/apps/cloud/src/auth/guards/jwt-access-token.guard.tsindex acf11ae8b..e94f1621f 100644--- a/backend/apps/cloud/src/auth/guards/jwt-access-token.guard.ts+++ b/backend/apps/cloud/src/auth/guards/jwt-access-token.guard.ts@@ -1,7 +1,7 @@import { Injectable, ExecutionContext } from '@nestjs/common'import { Reflector } from '@nestjs/core'import { AuthGuard } from '@nestjs/passport'-import { IS_PUBLIC_KEY } from '../decorators'+import { IS_PUBLIC_KEY, IS_OPTIONAL_AUTH_KEY } from '../decorators'@Injectable()export class JwtAccessTokenGuard extends AuthGuard('jwt-access-token') {@@ -19,4 +19,21 @@ export class JwtAccessTokenGuard extends AuthGuard('jwt-access-token') {return super.canActivate(context)}++ handleRequest(+ err: any,+ user: any,+ info: any,+ context: ExecutionContext,+ status?: any,+ ) {+ const isOptionalAuth = this.reflector.getAllAndOverride<boolean>(+ IS_OPTIONAL_AUTH_KEY,+ [context.getHandler(), context.getClass()],+ )++ if (isOptionalAuth) return user++ return super.handleRequest(err, user, info, context, status)+ }}diff --git a/backend/apps/community/src/auth/guards/jwt-access-token.guard.ts b/backend/apps/community/src/auth/guards/jwt-access-token.guard.tsindex 0a9067747..4f1409ad4 100644--- a/backend/apps/community/src/auth/guards/jwt-access-token.guard.ts+++ b/backend/apps/community/src/auth/guards/jwt-access-token.guard.ts@@ -2,7 +2,7 @@ import { Injectable, ExecutionContext } from '@nestjs/common'import { Reflector } from '@nestjs/core'import { AuthGuard } from '@nestjs/passport'import { Observable } from 'rxjs'-import { IS_PUBLIC_KEY } from '../decorators'+import { IS_PUBLIC_KEY, IS_OPTIONAL_AUTH_KEY } from '../decorators'@Injectable()export class JwtAccessTokenGuard extends AuthGuard('jwt-access-token') {@@ -22,4 +22,21 @@ export class JwtAccessTokenGuard extends AuthGuard('jwt-access-token') {return super.canActivate(context)}++ handleRequest(+ err: any,+ user: any,+ info: any,+ context: ExecutionContext,+ status?: any,+ ) {+ const isOptionalAuth = this.reflector.getAllAndOverride<boolean>(+ IS_OPTIONAL_AUTH_KEY,+ [context.getHandler(), context.getClass()],+ )++ if (isOptionalAuth) return user++ return super.handleRequest(err, user, info, context, status)+ }}