mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2026-03-10 17:11:44 +00:00
- Introduced optional timezone fields in User and Device entities to store user preferences and device timezones. - Updated request DTOs for login and user updates to include timezone information. - Enhanced AuthService to handle timezone during device registration and updates. - Added migration to incorporate timezone fields in the database schema.
48 lines
1.8 KiB
TypeScript
48 lines
1.8 KiB
TypeScript
import { ApiProperty } from '@nestjs/swagger';
|
|
import { IsEmail, IsEnum, IsNotEmpty, IsOptional, IsString, Matches, ValidateIf } from 'class-validator';
|
|
import { i18nValidationMessage as i18n } from 'nestjs-i18n';
|
|
import { COUNTRY_CODE_REGEX } from '~/auth/constants';
|
|
import { GrantType } from '~/auth/enums';
|
|
import { IsValidPhoneNumber } from '~/core/decorators/validations';
|
|
export class LoginRequestDto {
|
|
@ApiProperty({ example: '+962' })
|
|
@Matches(COUNTRY_CODE_REGEX, {
|
|
message: i18n('validation.Matches', { path: 'general', property: 'auth.countryCode' }),
|
|
})
|
|
countryCode!: string;
|
|
|
|
@ApiProperty({ example: '787259134' })
|
|
@IsValidPhoneNumber({
|
|
message: i18n('validation.IsValidPhoneNumber', { path: 'general', property: 'auth.phoneNumber' }),
|
|
})
|
|
phoneNumber!: string;
|
|
|
|
@ApiProperty({ example: 'Abcd1234@' })
|
|
@IsString({ message: i18n('validation.IsString', { path: 'general', property: 'auth.password' }) })
|
|
@ValidateIf((o) => o.grantType === GrantType.PASSWORD)
|
|
password!: string;
|
|
|
|
@ApiProperty({ example: 'device-123', description: 'Unique device identifier', required: false })
|
|
@IsOptional()
|
|
@IsString({ message: i18n('validation.IsString', { path: 'general', property: 'auth.deviceId' }) })
|
|
deviceId?: string;
|
|
|
|
@ApiProperty({
|
|
example: 'cXYzABC:APA91bHunvwY7rKpn8N7y6vDxS0qmQ5RZx2C8K...',
|
|
description: 'Firebase Cloud Messaging token for push notifications',
|
|
required: false,
|
|
})
|
|
@IsOptional()
|
|
@IsString({ message: i18n('validation.IsString', { path: 'general', property: 'auth.fcmToken' }) })
|
|
fcmToken?: string;
|
|
|
|
@ApiProperty({
|
|
example: 'Asia/Riyadh',
|
|
description: 'Device timezone (auto-detected from device OS)',
|
|
required: false,
|
|
})
|
|
@IsOptional()
|
|
@IsString({ message: i18n('validation.IsString', { path: 'general', property: 'auth.timezone' }) })
|
|
timezone?: string;
|
|
}
|