feat: add Twitter social login support by updating the auth service and user schema.

This commit is contained in:
pradeepkumar
2025-12-22 16:49:37 +05:30
parent 14e78d80e7
commit 099622dc88
2 changed files with 10 additions and 2 deletions

View File

@@ -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())

View File

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