Files
backend/src/auth/dto/social-auth.dto.ts

69 lines
1.6 KiB
TypeScript
Raw Normal View History

import {
IsEmail,
IsString,
IsEnum,
IsOptional,
IsUrl,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
export class SocialAuthDto {
@ApiProperty({
example: 'google',
description: 'OAuth provider',
2026-03-26 15:18:59 +05:30
enum: ['google', 'facebook', 'twitter', 'apple'],
})
2026-03-26 15:18:59 +05:30
@IsEnum(['google', 'facebook', 'twitter', 'apple'], {
message: 'Provider must be google, facebook, twitter, or apple',
})
2026-03-26 15:18:59 +05:30
provider: 'google' | 'facebook' | 'twitter' | 'apple';
@ApiProperty({
example: '123456789',
description: 'Provider user ID',
})
@IsString()
providerId: string;
@ApiProperty({
example: 'john@example.com',
description: 'User email from OAuth provider',
})
@IsEmail({}, { message: 'Please provide a valid email address' })
email: string;
@ApiPropertyOptional({
example: 'John Doe',
description: 'User name from OAuth provider',
})
@IsOptional()
@IsString()
name?: string;
@ApiPropertyOptional({
example: 'https://example.com/avatar.jpg',
description: 'User avatar URL from OAuth provider',
})
@IsOptional()
@IsUrl({}, { message: 'Avatar must be a valid URL' })
avatar?: string;
@ApiPropertyOptional({
example: 'USER',
description: 'User role (USER or AGENT)',
enum: ['USER', 'AGENT'],
default: 'USER',
})
@IsOptional()
@IsEnum(['USER', 'AGENT'], { message: 'Role must be either USER or AGENT' })
role?: 'USER' | 'AGENT';
2026-03-26 15:18:59 +05:30
@ApiPropertyOptional({
example: 'uuid-of-agent-type',
description: 'Agent type ID (required when role is AGENT)',
})
@IsOptional()
@IsString()
agentTypeId?: string;
}