From 7affab06f157247a5d0d1815cfa30af45132be99 Mon Sep 17 00:00:00 2001 From: Mahdi Date: Sun, 31 May 2026 20:43:11 +0330 Subject: [PATCH] update password --- src/modules/auth/auth.service.ts | 10 ---------- src/modules/auth/dto/set-password.dto.ts | 10 ++-------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/src/modules/auth/auth.service.ts b/src/modules/auth/auth.service.ts index d837b52..1380e69 100644 --- a/src/modules/auth/auth.service.ts +++ b/src/modules/auth/auth.service.ts @@ -203,16 +203,6 @@ export class AuthService { throw new UnauthorizedException('User not found'); } - if (user.passwordHash) { - if (!dto.currentPassword) { - throw new BadRequestException('Current password is required'); - } - const valid = await verifyPassword(dto.currentPassword, user.passwordHash); - if (!valid) { - throw new UnauthorizedException('Current password is incorrect'); - } - } - user.passwordHash = await hashPassword(dto.password); const saved = await this.users.save(user); return serializeUser(saved); diff --git a/src/modules/auth/dto/set-password.dto.ts b/src/modules/auth/dto/set-password.dto.ts index 4ebd1b3..1faa7b0 100644 --- a/src/modules/auth/dto/set-password.dto.ts +++ b/src/modules/auth/dto/set-password.dto.ts @@ -1,13 +1,7 @@ -import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; -import { IsOptional, IsString, MaxLength, MinLength } from 'class-validator'; +import { ApiProperty } from '@nestjs/swagger'; +import { IsString, MaxLength, MinLength } from 'class-validator'; export class SetPasswordDto { - @ApiPropertyOptional({ description: 'Required when changing an existing password' }) - @IsOptional() - @IsString() - @MaxLength(72) - currentPassword?: string; - @ApiProperty({ example: 'mySecurePass123', minLength: 8 }) @IsString() @MinLength(8)