chore: user setting module
This commit is contained in:
@@ -9,6 +9,7 @@ import { PasswordService } from "../../utils/providers/password.service";
|
||||
import { CompleteRegistrationDto } from "../DTO/complete-register.dto";
|
||||
import { CheckUserExistDto, LoginPasswordDTO } from "../DTO/loginPassword.dto";
|
||||
import { RequestOtpDto } from "../DTO/request-otp.dto";
|
||||
import { UpdatePasswordDto } from "../DTO/update-password.dto";
|
||||
import { VerifyOtpDto } from "../DTO/verify-otp.dto";
|
||||
|
||||
@Injectable()
|
||||
@@ -152,6 +153,23 @@ export class AuthService {
|
||||
};
|
||||
}
|
||||
//****************** */
|
||||
|
||||
async updatePassword(userId: string, updateDto: UpdatePasswordDto) {
|
||||
const { user } = await this.usersService.findOneById(userId);
|
||||
|
||||
const passCompare = await this.passwordService.comparePassword(updateDto.password, user.password);
|
||||
if (!passCompare) throw new BadRequestException(AuthMessage.INVALID_PASSWORD);
|
||||
|
||||
if (updateDto.newPassword !== updateDto.repeatPassword) throw new BadRequestException(AuthMessage.INVALID_REAPET_PASSWORD);
|
||||
|
||||
const hashedPassword = await this.passwordService.hashPassword(updateDto.newPassword);
|
||||
await this.usersService.updateUserPassword(user.id, hashedPassword);
|
||||
|
||||
return {
|
||||
message: AuthMessage.PASSWORD_CHANGED_SUCCESSFULLY,
|
||||
};
|
||||
}
|
||||
|
||||
//****************** */
|
||||
|
||||
private async checkUserLoginCredentialWithEmail(email: string, password: string) {
|
||||
|
||||
Reference in New Issue
Block a user