From e9f135e9b75f294b7bbcaba058e41ff38aef84da Mon Sep 17 00:00:00 2001 From: pradeepkumar Date: Thu, 26 Mar 2026 15:18:59 +0530 Subject: [PATCH] fix --- prisma/schema.prisma | 2 ++ src/auth/auth.service.ts | 9 +++++++-- src/auth/dto/social-auth.dto.ts | 16 ++++++++++++---- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index fbb44ef..dc54919 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -32,6 +32,7 @@ enum AuthProvider { GOOGLE FACEBOOK TWITTER + APPLE } enum FieldType { @@ -110,6 +111,7 @@ model User { googleId String? @unique facebookId String? @unique twitterId String? @unique + appleId String? @unique // Two-Factor Authentication twoFactorEnabled Boolean @default(false) diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index ee8c6c0..8f8e741 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -227,7 +227,9 @@ export class AuthService { ? 'googleId' : dto.provider === 'facebook' ? 'facebookId' - : 'twitterId'; + : dto.provider === 'apple' + ? 'appleId' + : 'twitterId'; // Check if user exists with this provider ID let user = await this.prisma.user.findFirst({ @@ -262,7 +264,9 @@ export class AuthService { ? AuthProvider.GOOGLE : dto.provider === 'facebook' ? AuthProvider.FACEBOOK - : AuthProvider.TWITTER; + : dto.provider === 'apple' + ? AuthProvider.APPLE + : AuthProvider.TWITTER; // Parse name const nameParts = dto.name?.split(' ') || []; @@ -304,6 +308,7 @@ export class AuthService { firstName, lastName, avatar: dto.avatar, + agentTypeId: dto.agentTypeId || undefined, }, }); } diff --git a/src/auth/dto/social-auth.dto.ts b/src/auth/dto/social-auth.dto.ts index f14ea23..4e14cdf 100644 --- a/src/auth/dto/social-auth.dto.ts +++ b/src/auth/dto/social-auth.dto.ts @@ -11,12 +11,12 @@ export class SocialAuthDto { @ApiProperty({ example: 'google', description: 'OAuth provider', - enum: ['google', 'facebook'], + enum: ['google', 'facebook', 'twitter', 'apple'], }) - @IsEnum(['google', 'facebook'], { - message: 'Provider must be either google or facebook', + @IsEnum(['google', 'facebook', 'twitter', 'apple'], { + message: 'Provider must be google, facebook, twitter, or apple', }) - provider: 'google' | 'facebook'; + provider: 'google' | 'facebook' | 'twitter' | 'apple'; @ApiProperty({ example: '123456789', @@ -57,4 +57,12 @@ export class SocialAuthDto { @IsOptional() @IsEnum(['USER', 'AGENT'], { message: 'Role must be either USER or AGENT' }) role?: 'USER' | 'AGENT'; + + @ApiPropertyOptional({ + example: 'uuid-of-agent-type', + description: 'Agent type ID (required when role is AGENT)', + }) + @IsOptional() + @IsString() + agentTypeId?: string; }