Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ export class AuthController {
data: {
isValid,
},
message: isValid ? 'Password is correct' : 'Password is incorrect',
message: 'Correct Password',
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded message 'Correct Password' is inconsistent with the new error handling in the service. Since verifyCurrentPassword now throws a BadRequestException for incorrect passwords (line 195 in password.service.ts), the conditional message is no longer needed. However, the isValid field in the response data (line 773) will always be true when this line is reached, making it redundant. Consider updating the API documentation to reflect that this endpoint now throws a 400 error for incorrect passwords instead of returning isValid: false.

Copilot uses AI. Check for mistakes.
};
}
}
6 changes: 5 additions & 1 deletion src/auth/services/password/password.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ export class PasswordService {
throw new NotFoundException('User not found');
}

return await this.verify(user.password, password);
const isMatched: boolean = await this.verify(user.password, password);
if (isMatched) {
return true;
}
throw new BadRequestException('incorrect password');
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message should be capitalized to match the pattern used in other error messages in the codebase. For example, line 174 uses "Old password is incorrect" with proper capitalization.

Suggested change
throw new BadRequestException('incorrect password');
throw new BadRequestException('Incorrect password');

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API design has a fundamental issue. The service method now throws a BadRequestException when the password is incorrect (line 195), which means it will never return false. However, the controller code still expects a boolean return value and includes isValid in the response data (line 773). This creates an inconsistent API where:

  1. If the password is correct, it returns { status: 'success', data: { isValid: true }, message: 'Correct Password' }
  2. If the password is incorrect, it throws an exception instead of returning { data: { isValid: false } }

This breaks the original API contract where the endpoint would return both success and failure states without throwing exceptions. Either:

  • Remove the exception and return false when the password is incorrect (reverting to the original behavior), OR
  • Remove the isValid field from the response data since it will always be true if the endpoint doesn't throw an exception
Suggested change
throw new BadRequestException('incorrect password');
return false;

Copilot uses AI. Check for mistakes.
}
}
Loading