Skip to content

📈 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!

optional user

Blue Mouse2a6b4a8039a2
diff --git a/backend/apps/cloud/src/auth/guards/authentication.guard.ts b/backend/apps/cloud/src/auth/guards/authentication.guard.ts
index f43468c54..ffaec491b 100644
--- a/backend/apps/cloud/src/auth/guards/authentication.guard.ts
+++ b/backend/apps/cloud/src/auth/guards/authentication.guard.ts
@@ -23,7 +23,7 @@ export class AuthenticationGuard implements CanActivate {
const request = context.switchToHttp().getRequest()
const userFromRequest = request.user
- const user = await this.userService.findUserById(userFromRequest.id)
+ const user = await this.userService.findUserById(userFromRequest?.id)
let token = ''
if (request.cookies.token) {
@@ -47,7 +47,7 @@ export class AuthenticationGuard implements CanActivate {
// If the user has 2FA enabled, but the token is temporary (meant to be used for 2FA routes only) then return false
if (
- user.isTwoFactorAuthenticationEnabled &&
+ user?.isTwoFactorAuthenticationEnabled &&
!decoded.isSecondFactorAuthenticated
) {
return false