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!

some improvements

Blue Mousea446f452c8fe
diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts
index 6f6446a04..1e2abeebf 100644
--- a/src/auth/auth.controller.ts
+++ b/src/auth/auth.controller.ts
@@ -5,6 +5,7 @@ import {
UsePipes,
ValidationPipe,
Post,
+ Delete,
Body,
Ip,
ConflictException,
@@ -105,12 +106,10 @@ export class AuthController {
body.password,
)
- const { accessToken, refreshToken } =
- await this.authService.generateJwtTokens(newUser.id, true)
+ const jwtTokens = await this.authService.generateJwtTokens(newUser.id, true)
return {
- accessToken,
- refreshToken,
+ ...jwtTokens,
user: this.userService.omitSensitiveData(newUser),
}
}
@@ -481,7 +480,7 @@ export class AuthController {
})
@UseGuards(RolesGuard)
@Roles(UserType.CUSTOMER, UserType.ADMIN)
- @Post('google/unlink')
+ @Delete('google/unlink')
public async unlinkGoogleFromAccount(
@CurrentUserId() userId: string,
): Promise<void> {
diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts
index cee730105..973821315 100644
--- a/src/auth/auth.service.ts
+++ b/src/auth/auth.service.ts
@@ -470,8 +470,7 @@ export class AuthService {
}
return {
- accessToken: jwtTokens.accessToken,
- refreshToken: jwtTokens.refreshToken,
+ ...jwtTokens,
user: this.userService.omitSensitiveData(user),
}
}
@@ -484,6 +483,8 @@ export class AuthService {
.add(TRIAL_DURATION, 'day')
.format('YYYY-MM-DD HH:mm:ss'),
registeredWithGoogle: true,
+ isActive: true,
+ emailRequests: 0,
}
const userWithSameEmail = await this.userService.findOneWhere({
diff --git a/src/user/dto/user-google.dto.ts b/src/user/dto/user-google.dto.ts
index 9e80067e0..025fb1e0b 100644
--- a/src/user/dto/user-google.dto.ts
+++ b/src/user/dto/user-google.dto.ts
@@ -17,4 +17,10 @@ export class UserGoogleDTO {
@ApiProperty({ example: '[email protected]', required: false })
@IsEmail()
email?: string
+
+ @ApiProperty({ example: 1, required: false })
+ emailRequests: number
+
+ @ApiProperty({ example: true, required: false })
+ isActive: boolean
}
diff --git a/src/user/user.service.ts b/src/user/user.service.ts
index 4b90c5a03..07e7a75ab 100644
--- a/src/user/user.service.ts
+++ b/src/user/user.service.ts
@@ -70,7 +70,6 @@ export class UserService {
'password',
'twoFactorRecoveryCode',
'twoFactorAuthenticationSecret',
- 'googleId',
])
}