Skip to content
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

New API endpoint to change the users' password #619

Conversation

josecelano
Copy link
Member

New API endpoint to change the users' password.

This only adds the enpoint which alwyas returns a 404 response.
TODO:

- Validate new password.
- Extract duplicate code for pass validation.
- Tests
for password validation and hashing.
This is an extra security check. Before changing the password the user
must provide the current one.
@josecelano josecelano force-pushed the 618-new-api-endpoint-to-change-the-users-password branch from a390cf7 to 95e5019 Compare June 5, 2024 09:46
@josecelano
Copy link
Member Author

ACK 95e5019

josecelano added a commit to torrust/torrust-index-gui that referenced this pull request Jun 5, 2024
9e87ed5 feat: [#468] allow users to change the password (Jose Celano)

Pull request description:

  Depends on:

  - torrust/torrust-index-api-lib#45
  - torrust/torrust-index#619

  Allow users to change their passwords.

ACKs for top commit:
  josecelano:
    ACK 9e87ed5

Tree-SHA512: f461ae95d2719e4d95ea1959383f9be8818e5ddcf6e5619fa11d668ca13c82f12f1852ad8369f3484c7360d0fb1b4be5db4c2d15a237af80443dea7fa1867e8f
@josecelano josecelano merged commit 97b7c54 into torrust:develop Jun 5, 2024
11 of 13 checks passed
@@ -65,7 +65,7 @@ impl Service {
.await
.map_err(|_| ServiceError::InternalServerError)?;

verify_password(password.as_bytes(), &user_authentication)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Just out of curiosity, why are you wrapping the ServiceError::InvalidPassword to a ServiceError:WrongPasswordOrUsername. Is it because you want to have the Invalid password error info in the validate_password function and then return a more generic error to the caller?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hi @josecelano, In the "change password" form, I want to inform the user that the current password is not valid. However, in the "login form," I don't want to reveal why the login failed, whether it was because of a wrong email or password. If we returned the "invalid password," people could use the login form to find out if a given email/username is registered in the application.

Copy link
Contributor

@mario-nt mario-nt left a comment

Choose a reason for hiding this comment

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

Looks good!

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

Successfully merging this pull request may close these issues.

New API endpoint to change the user's password
2 participants