update password
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user