hyperswitch icon indicating copy to clipboard operation
hyperswitch copied to clipboard

fix(users): add password validations

Open Riddhiagrawal001 opened this issue 9 months ago • 0 comments

Type of Change

  • [ ] Bugfix
  • [ ] New feature
  • [X] Enhancement
  • [ ] Refactoring
  • [ ] Dependency updates
  • [ ] Documentation
  • [ ] CI/CD

Description

Closes https://github.com/juspay/hyperswitch/issues/4412

Additional Changes

  • [ ] This PR modifies the API contract
  • [ ] This PR modifies the database schema
  • [ ] This PR modifies application configuration/environment variables

Motivation and Context

The mandatory condition for the password field was just not be empty . Following the PR, the password field will be subject to the following checks: 1.The password must be between 8 and 50 characters in length. 2.It must include at least one uppercase character. 3.It must include at least one lowercase character. 4.It must include at least one special character. 5.It must include at least one numeric character. 6.It must not contain whitespace.

How did you test it?

1.Signup API ( local testing)

curl --location 'http://localhost:8080/user/signup' \
--header 'Content-Type: application/json' \
--data-raw '{
    "email": "email value",
    "password": "456667sdvh",
    "country": "IN"
}'

Failure case response

    "error": {
        "type": "invalid_request",
        "message": "Invalid Password",
        "code": "UR_09"
    }
} 

2.Reset Password API (local testing)

curl --location 'http://localhost:8080/user/reset_password' \
--header 'Content-Type: application/json' \
--data '{
    "password": "456667sdvd",
    "token":"token from email after clicking Reset password in dashboard"
}'

Failure case response

{
    "error": {
        "type": "invalid_request",
        "message": "Invalid Password",
        "code": "UR_09"
    }
} 

Checklist

  • [X] I formatted the code cargo +nightly fmt --all
  • [X] I addressed lints thrown by cargo clippy
  • [ ] I reviewed the submitted code
  • [ ] I added unit tests for my changes where possible

Riddhiagrawal001 avatar May 06 '24 07:05 Riddhiagrawal001