Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feature/#38 Added reset password endpoint #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
Loading
from

Conversation

Ivanruii
Copy link
Collaborator

Closed #38

@manudous manudous requested a review from Copilot May 21, 2025 06:16
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds a new change-password endpoint that validates the old password, hashes the new one, and updates the user record.

  • Introduces validationChangePassword to enforce required fields and verify the current password.
  • Exposes the validator in the validations index and integrates it into the REST API.
  • Extends the API model with ChangePasswordParams and adds a new internal error code.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/pods/user/validations/password-validation.ts New validationChangePassword function with field checks and hash verification.
src/pods/user/validations/index.ts Exports the new validationChangePassword validator.
src/pods/user/user.api-model.ts Defines ChangePasswordParams interface.
src/common/custom-error/custom-error.model.ts Adds InvalidPassword to CustomInternalCodes.
src/pods/user/user.rest-api.ts Adds /change-password route, applies validation, hashing, and status mapping.
Comments suppressed due to low confidence (2)

src/pods/user/user.api-model.ts:33

  • [nitpick] Using Spanish identifiers with accents (e.g., contraseñaActual) may cause encoding or consistency issues; consider using English names like currentPassword.
  contraseñaActual: string;

src/pods/user/user.rest-api.ts:120

  • The new /change-password endpoint and its validation logic lack accompanying tests; consider adding unit and integration tests to cover the success and error flows.
.post('/change-password', async (req, res, next) => {

Comment on lines +10 to +23
return { succeded: false, error: { error: CustomInternalCodes.FieldNotInformed } };
}

const user = await userRepository.getUser(passwordData.id);
if (!user) {
return { succeded: false, error: { error: CustomInternalCodes.UserNotFound } };
}

const isValidPassword = await verifyHash(passwordData.contraseñaActual, user.contraseña);
if (!isValidPassword) {
return { succeded: false, error: { error: CustomInternalCodes.InvalidPassword } };
}

return { succeded: true };
Copy link
Preview

Copilot AI May 21, 2025

Choose a reason for hiding this comment

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

The property succeded appears misspelled; it should likely be succeeded to match common spelling and avoid mismatches with the ValidationInfo interface.

Suggested change
return { succeded: false, error: { error: CustomInternalCodes.FieldNotInformed } };
}
const user = await userRepository.getUser(passwordData.id);
if (!user) {
return { succeded: false, error: { error: CustomInternalCodes.UserNotFound } };
}
const isValidPassword = await verifyHash(passwordData.contraseñaActual, user.contraseña);
if (!isValidPassword) {
return { succeded: false, error: { error: CustomInternalCodes.InvalidPassword } };
}
return { succeded: true };
return { succeeded: false, error: { error: CustomInternalCodes.FieldNotInformed } };
}
const user = await userRepository.getUser(passwordData.id);
if (!user) {
return { succeeded: false, error: { error: CustomInternalCodes.UserNotFound } };
}
const isValidPassword = await verifyHash(passwordData.contraseñaActual, user.contraseña);
if (!isValidPassword) {
return { succeeded: false, error: { error: CustomInternalCodes.InvalidPassword } };
}
return { succeeded: true };

Copilot uses AI. Check for mistakes.

Positive FeedbackNegative Feedback

if (validationResult.succeded) {
const hashedPassword = await hash(passwordData.nuevaContraseña);
const user = await userRepository.getUser(passwordData.id);
Copy link
Preview

Copilot AI May 21, 2025

Choose a reason for hiding this comment

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

[nitpick] This call fetches the user again after validation already retrieved it; you could return the user from the validation step to reduce an extra database query.

Copilot uses AI. Check for mistakes.

Positive FeedbackNegative Feedback
res.sendStatus(204);
} else {
const statusCode = (() => {
switch (validationResult.error?.error) {
Copy link
Preview

Copilot AI May 21, 2025

Choose a reason for hiding this comment

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

The FieldNotInformed case currently falls through to the default status 400; mapping it explicitly to 422 (like UserNotFound) may better communicate input validation errors.

Copilot uses AI. Check for mistakes.

Positive FeedbackNegative Feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Backend] resetear clave
1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.