Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Sign up
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Ivanruii wants to merge1 commit intomain
base:main
Choose a base branch
Loading
fromfeature-#38-reset-password

Conversation

Ivanruii
Copy link
Collaborator

Closed#38

@manudousmanudous requested a review fromCopilotMay 21, 2025 06:16
Copy link

@CopilotCopilotAI 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.

  • IntroducesvalidationChangePassword 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 withChangePasswordParams 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
FileDescription
src/pods/user/validations/password-validation.tsNewvalidationChangePassword function with field checks and hash verification.
src/pods/user/validations/index.tsExports the newvalidationChangePassword validator.
src/pods/user/user.api-model.tsDefinesChangePasswordParams interface.
src/common/custom-error/custom-error.model.tsAddsInvalidPassword toCustomInternalCodes.
src/pods/user/user.rest-api.tsAdds/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 likecurrentPassword.
  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

CopilotAIMay 21, 2025

Choose a reason for hiding this comment

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

The propertysucceded appears misspelled; it should likely besucceeded to match common spelling and avoid mismatches with theValidationInfo interface.

Suggested change
return{succeded:false,error:{error:CustomInternalCodes.FieldNotInformed}};
}
constuser=awaituserRepository.getUser(passwordData.id);
if(!user){
return{succeded:false,error:{error:CustomInternalCodes.UserNotFound}};
}
constisValidPassword=awaitverifyHash(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}};
}
constuser=awaituserRepository.getUser(passwordData.id);
if(!user){
return{succeeded:false,error:{error:CustomInternalCodes.UserNotFound}};
}
constisValidPassword=awaitverifyHash(passwordData.contraseñaActual,user.contraseña);
if(!isValidPassword){
return{succeeded:false,error:{error:CustomInternalCodes.InvalidPassword}};
}
return{succeeded:true};

Copilot uses AI. Check for mistakes.


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

CopilotAIMay 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.

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

CopilotAIMay 21, 2025

Choose a reason for hiding this comment

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

TheFieldNotInformed case currently falls through to the default status 400; mapping it explicitly to 422 (likeUserNotFound) may better communicate input validation errors.

Copilot uses AI. Check for mistakes.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

Copilot code reviewCopilotCopilot left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

[Backend] resetear clave
1 participant
@Ivanruii

[8]ページ先頭

©2009-2025 Movatter.jp