import { Controller , Post , Body , UseGuards , Res , HttpStatus , } from '@nestjs/common' ; import { ChangePasswordService } from '../change-password/change-password.service' ; import { AuthGuard } from '@nestjs/passport' ; import { ChangePasswordDto } from './dto/change-password.dto' ; @ UseGuards ( AuthGuard ( 'jwt' ) ) @ Controller ( 'auth/change-password' ) export class ChangePasswordController { constructor ( private readonly changePasswordService ) { } @ Post ( ) public async changePassword ( @ Res ( ) res , @ Body ( ) changePasswordDto ) { try { await this . changePasswordService . changePassword ( changePasswordDto ) ; return res . status ( HttpStatus . OK ) . json ( { message : 'Request Change Password Successfully!' , status : 200 , } ) ; } catch ( err ) { return res . status ( HttpStatus . BAD_REQUEST ) . json ( { message : 'Error: Change password failed!' , status : 400 , } ) ; } } }