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 some conditions to unlinkGoogleAccount

Blue Mouse5b3afe2f2045
diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts
index e3e50db99..cee730105 100644
--- a/src/auth/auth.service.ts
+++ b/src/auth/auth.service.ts
@@ -638,6 +638,18 @@ export class AuthService {
}
async unlinkGoogleAccount(userId: string) {
+ const user = await this.userService.findUserById(userId)
+
+ if (!user) {
+ throw new BadRequestException('User not found')
+ }
+
+ if (user.registeredWithGoogle) {
+ throw new BadRequestException(
+ 'You cannot unlink your Google account if you registered with it',
+ )
+ }
+
await this.userService.updateUser(userId, {
googleId: null,
})