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!

fixed 2fa issue

Blue Mouse495b29a394ab
diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts
index 808a35b72..5aab5a065 100644
--- a/src/auth/auth.controller.ts
+++ b/src/auth/auth.controller.ts
@@ -103,7 +103,7 @@ export class AuthController {
body.password,
)
- const jwtTokens = await this.authService.generateJwtTokens(newUser.id)
+ const jwtTokens = await this.authService.generateJwtTokens(newUser.id, true)
return {
accessToken: jwtTokens.accessToken,
@@ -139,7 +139,7 @@ export class AuthController {
await this.authService.sendTelegramNotification(user.id, headers, ip)
- const jwtTokens = await this.authService.generateJwtTokens(user.id)
+ const jwtTokens = await this.authService.generateJwtTokens(user.id, !user.isTwoFactorAuthenticationEnabled)
if (user.isTwoFactorAuthenticationEnabled) {
user = _pick(user, ['isTwoFactorAuthenticationEnabled', 'email'])
diff --git a/src/auth/guards/roles.guard.ts b/src/auth/guards/roles.guard.ts
index 9b7a5ad5c..cfab240ed 100644
--- a/src/auth/guards/roles.guard.ts
+++ b/src/auth/guards/roles.guard.ts
@@ -36,7 +36,7 @@ export class RolesGuard implements CanActivate {
if (
!isTwoFaNotRequired &&
user.isTwoFactorAuthenticationEnabled &&
- !userFromRequest.isSecondFactorAuthenticated
+ userFromRequest.isSecondFactorAuthenticated
) {
return false
}
diff --git a/src/twoFactorAuth/twoFactorAuth.controller.ts b/src/twoFactorAuth/twoFactorAuth.controller.ts
index 2bfe09aa5..876839b31 100644
--- a/src/twoFactorAuth/twoFactorAuth.controller.ts
+++ b/src/twoFactorAuth/twoFactorAuth.controller.ts
@@ -171,6 +171,11 @@ export class TwoFactorAuthController {
throw new BadRequestException('Wrong authentication code')
}
- return await this.authService.generateJwtTokens(user.id, true)
+ const tokens = await this.authService.generateJwtTokens(user.id, true)
+
+ return {
+ ...tokens,
+ user: this.userService.omitSensitiveData(user),
+ }
}
}