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!

Added an additional field in the login response

Yevhenii Kulisidi58dd725ae261
diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts
index 86f632c4f..c3cb8edc4 100644
--- a/src/auth/auth.controller.ts
+++ b/src/auth/auth.controller.ts
@@ -139,6 +139,7 @@ export class AuthController {
return {
accessToken: jwtTokens.accessToken,
refreshToken: jwtTokens.refreshToken,
+ isTwoFactorAuthenticationEnabled: user.isTwoFactorAuthenticationEnabled,
}
}
diff --git a/src/auth/dtos/login.dto.ts b/src/auth/dtos/login.dto.ts
index 0e16aaa90..ca49e09fe 100644
--- a/src/auth/dtos/login.dto.ts
+++ b/src/auth/dtos/login.dto.ts
@@ -1,11 +1,24 @@
-import { OmitType, PickType } from '@nestjs/swagger'
+import {
+ ApiProperty,
+ IntersectionType,
+ OmitType,
+ PickType,
+} from '@nestjs/swagger'
import { RegisterRequestDto, RegisterResponseDto } from './register.dto'
export class LoginRequestDto extends OmitType(RegisterRequestDto, [
'checkIfLeaked',
] as const) {}
-export class LoginResponseDto extends PickType(RegisterResponseDto, [
- 'accessToken',
- 'refreshToken',
-] as const) {}
+class AdditionalInfo {
+ @ApiProperty({
+ description: 'Is two factor authentication enabled',
+ example: false,
+ })
+ isTwoFactorAuthenticationEnabled: boolean
+}
+
+export class LoginResponseDto extends IntersectionType(
+ PickType(RegisterResponseDto, ['accessToken', 'refreshToken'] as const),
+ AdditionalInfo,
+) {}