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";
|
import { AuthMessage } from "../../../common/enums/message.enum";
|
||||||
|
|
||||||
export class ChangePasswordDto {
|
export class ChangePasswordDto {
|
||||||
@IsNotEmpty({ message: AuthMessage.PASSWORD_NOT_EMPTY })
|
// @IsNotEmpty({ message: AuthMessage.PASSWORD_NOT_EMPTY })
|
||||||
@IsString({ message: AuthMessage.PASSWORD_FORMAT_INVALID })
|
// @IsString({ message: AuthMessage.PASSWORD_FORMAT_INVALID })
|
||||||
@ApiProperty({ description: "old password", example: "12S345SS678" })
|
// @ApiProperty({ description: "old password", example: "12S345SS678" })
|
||||||
@MinLength(8, { message: AuthMessage.PASSWORD_LENGTH })
|
// @MinLength(8, { message: AuthMessage.PASSWORD_LENGTH })
|
||||||
password: string;
|
// password: string;
|
||||||
|
|
||||||
@IsNotEmpty({ message: AuthMessage.PASSWORD_NOT_EMPTY })
|
@IsNotEmpty({ message: AuthMessage.PASSWORD_NOT_EMPTY })
|
||||||
@IsString({ message: AuthMessage.PASSWORD_FORMAT_INVALID })
|
@IsString({ message: AuthMessage.PASSWORD_FORMAT_INVALID })
|
||||||
|
|||||||
@@ -196,8 +196,8 @@ export class AuthService {
|
|||||||
async changePassword(userId: string, updateDto: ChangePasswordDto) {
|
async changePassword(userId: string, updateDto: ChangePasswordDto) {
|
||||||
const { user } = await this.usersService.findOneById(userId);
|
const { user } = await this.usersService.findOneById(userId);
|
||||||
|
|
||||||
const passCompare = await this.passwordService.comparePassword(updateDto.password, user.password);
|
// const passCompare = await this.passwordService.comparePassword(updateDto.password, user.password);
|
||||||
if (!passCompare) throw new BadRequestException(AuthMessage.CURRENT_PASSWORD_INVALID);
|
// if (!passCompare) throw new BadRequestException(AuthMessage.CURRENT_PASSWORD_INVALID);
|
||||||
|
|
||||||
if (updateDto.newPassword !== updateDto.repeatPassword) throw new BadRequestException(AuthMessage.INVALID_REAPET_PASSWORD);
|
if (updateDto.newPassword !== updateDto.repeatPassword) throw new BadRequestException(AuthMessage.INVALID_REAPET_PASSWORD);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user