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(' ') || [];