feat: add jwt auth guard and profile endpoint

This commit is contained in:
2026-02-28 08:14:04 +03:30
parent 8212ede785
commit 06f659101d
21 changed files with 371 additions and 31 deletions
@@ -0,0 +1,94 @@
import { MatchField } from '@/common/decorators/match-field.decorator';
import { ApiProperty } from '@nestjs/swagger';
import {
IsOptional,
IsString,
Matches,
MaxLength,
MinLength,
ValidateIf,
} from 'class-validator';
import { i18nValidationMessage as t } from 'nestjs-i18n';
export class UpdateProfileDTO {
@ApiProperty({
type: 'string',
description: `User's Firstname`,
example: 'Radmehr',
required: false,
})
@IsString()
@IsOptional()
@MinLength(3, {
message: t('validation.minLengthField', {
field: '$t(users.fields.firstName)',
min: 3,
}),
})
@MaxLength(96, {
message: t('validation.maxLengthField', {
field: '$t(users.fields.firstName)',
max: 96,
}),
})
firstName?: string;
@ApiProperty({
type: 'string',
description: `User's Lastname`,
example: 'Tarnas',
required: false,
})
@IsString()
@IsOptional()
@MinLength(3, {
message: t('validation.minLengthField', {
field: '$t(users.fields.lastName)',
min: 3,
}),
})
@MaxLength(96, {
message: t('validation.maxLengthField', {
field: '$t(users.fields.lastName)',
min: 3,
}),
})
lastName?: string;
@ApiProperty({
type: 'string',
description: 'Password for User Account',
example: 'Password1@',
required: false,
})
@IsString()
@IsOptional()
@MinLength(8, {
message: t('validation.minLengthField', {
field: '$t(users.fields.password)',
min: 8,
}),
})
@MaxLength(96, {
message: t('validation.maxLengthField', {
field: '$t(users.fields.password)',
max: 96,
}),
})
@Matches(/^(?=.*[A-Za-z])(?=.*\d)(?=.*[^A-Za-z\d]).{8,}$/, {
message: t('users.errors.passwordPattern'),
})
password?: string;
@ApiProperty({
type: 'string',
description: 'Confirm Password of User Account (Should match Password)',
example: 'Password1@',
required: false,
})
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
@ValidateIf((o) => o.password !== undefined)
@IsOptional()
@MatchField('password')
confirmPassword?: string;
}