feat: implement authenticated user password change functionality, including a new DTO, service method, and API endpoint.
This commit is contained in:
@@ -27,6 +27,7 @@ import {
|
||||
ResetPasswordDto,
|
||||
RefreshTokenDto,
|
||||
VerifyEmailDto,
|
||||
ChangePasswordDto,
|
||||
} from './dto';
|
||||
import {
|
||||
VerifyTwoFactorDto,
|
||||
@@ -201,6 +202,36 @@ export class AuthController {
|
||||
return this.authService.resetPassword(dto);
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// CHANGE PASSWORD
|
||||
// ==========================================
|
||||
@Post('change-password')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@ApiBearerAuth('JWT-auth')
|
||||
@ApiOperation({ summary: 'Change password for authenticated user' })
|
||||
@ApiBody({ type: ChangePasswordDto })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'Password changed successfully',
|
||||
schema: {
|
||||
example: {
|
||||
success: true,
|
||||
data: {
|
||||
message: 'Password changed successfully',
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
@ApiResponse({ status: 400, description: 'Current password is incorrect' })
|
||||
@ApiResponse({ status: 401, description: 'Unauthorized' })
|
||||
async changePassword(
|
||||
@CurrentUser('id') userId: string,
|
||||
@Body() dto: ChangePasswordDto,
|
||||
) {
|
||||
return this.authService.changePassword(userId, dto);
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// VERIFY EMAIL
|
||||
// ==========================================
|
||||
|
||||
Reference in New Issue
Block a user