update : password
This commit is contained in:
Generated
+21700
File diff suppressed because it is too large
Load Diff
@@ -4,11 +4,11 @@ import { IsNotEmpty, IsString, MinLength } from "class-validator";
|
||||
import { AuthMessage } from "../../../common/enums/message.enum";
|
||||
|
||||
export class ChangePasswordDto {
|
||||
@IsNotEmpty({ message: AuthMessage.PASSWORD_NOT_EMPTY })
|
||||
@IsString({ message: AuthMessage.PASSWORD_FORMAT_INVALID })
|
||||
@ApiProperty({ description: "old password", example: "12S345SS678" })
|
||||
@MinLength(8, { message: AuthMessage.PASSWORD_LENGTH })
|
||||
password: string;
|
||||
// @IsNotEmpty({ message: AuthMessage.PASSWORD_NOT_EMPTY })
|
||||
// @IsString({ message: AuthMessage.PASSWORD_FORMAT_INVALID })
|
||||
// @ApiProperty({ description: "old password", example: "12S345SS678" })
|
||||
// @MinLength(8, { message: AuthMessage.PASSWORD_LENGTH })
|
||||
// password: string;
|
||||
|
||||
@IsNotEmpty({ message: AuthMessage.PASSWORD_NOT_EMPTY })
|
||||
@IsString({ message: AuthMessage.PASSWORD_FORMAT_INVALID })
|
||||
|
||||
@@ -196,8 +196,8 @@ export class AuthService {
|
||||
async changePassword(userId: string, updateDto: ChangePasswordDto) {
|
||||
const { user } = await this.usersService.findOneById(userId);
|
||||
|
||||
const passCompare = await this.passwordService.comparePassword(updateDto.password, user.password);
|
||||
if (!passCompare) throw new BadRequestException(AuthMessage.CURRENT_PASSWORD_INVALID);
|
||||
// const passCompare = await this.passwordService.comparePassword(updateDto.password, user.password);
|
||||
// if (!passCompare) throw new BadRequestException(AuthMessage.CURRENT_PASSWORD_INVALID);
|
||||
|
||||
if (updateDto.newPassword !== updateDto.repeatPassword) throw new BadRequestException(AuthMessage.INVALID_REAPET_PASSWORD);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user