feat: Implement comprehensive user authentication with JWT, social login, and password management.
This commit is contained in:
60
src/auth/dto/social-auth.dto.ts
Normal file
60
src/auth/dto/social-auth.dto.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import {
|
||||
IsEmail,
|
||||
IsString,
|
||||
IsEnum,
|
||||
IsOptional,
|
||||
IsUrl,
|
||||
} from 'class-validator';
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
|
||||
export class SocialAuthDto {
|
||||
@ApiProperty({
|
||||
example: 'google',
|
||||
description: 'OAuth provider',
|
||||
enum: ['google', 'facebook'],
|
||||
})
|
||||
@IsEnum(['google', 'facebook'], {
|
||||
message: 'Provider must be either google or facebook',
|
||||
})
|
||||
provider: 'google' | 'facebook';
|
||||
|
||||
@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';
|
||||
}
|
||||
Reference in New Issue
Block a user