From 099622dc881c3da59a5bb39501a29b238c04df86 Mon Sep 17 00:00:00 2001 From: pradeepkumar Date: Mon, 22 Dec 2025 16:49:37 +0530 Subject: [PATCH] feat: add Twitter social login support by updating the auth service and user schema. --- prisma/schema.prisma | 2 ++ src/auth/auth.service.ts | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index dc2591f..6ebefeb 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -30,6 +30,7 @@ enum AuthProvider { LOCAL GOOGLE FACEBOOK + TWITTER } // =========================================== @@ -49,6 +50,7 @@ model User { authProvider AuthProvider @default(LOCAL) googleId String? @unique facebookId String? @unique + twitterId String? @unique // Timestamps createdAt DateTime @default(now()) diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index 299329c..b3e74c3 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -185,7 +185,11 @@ export class AuthService { // ========================================== async socialAuth(dto: SocialAuthDto) { const providerIdField = - dto.provider === 'google' ? 'googleId' : 'facebookId'; + dto.provider === 'google' + ? 'googleId' + : dto.provider === 'facebook' + ? 'facebookId' + : 'twitterId'; // Check if user exists with this provider ID let user = await this.prisma.user.findFirst({ @@ -218,7 +222,9 @@ export class AuthService { const authProvider = dto.provider === 'google' ? AuthProvider.GOOGLE - : AuthProvider.FACEBOOK; + : dto.provider === 'facebook' + ? AuthProvider.FACEBOOK + : AuthProvider.TWITTER; // Parse name const nameParts = dto.name?.split(' ') || [];