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

fix(users): Add force rotate password on first login for non-email flow #6483

Merged
merged 3 commits into from
Nov 7, 2024

Conversation

ThisIsMani
Copy link
Contributor

Type of Change

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

Description

Currently in non-email flow, users who are invited are not forced to change their password. This PR will add that.

Additional Changes

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

Motivation and Context

Closes #6482.

How did you test it?

  1. Invite a new user in non-email flow

    curl --location 'http://localhost:8080/user/user/invite_multiple?token_only=true' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiN2I2NTA1NGQtNjgzNC00NzU2LTgyNDYtN2RkOWM1ZmQzMzRmIiwibWVyY2hhbnRfaWQiOiJtZXJjaGFudF8xNzI5MTc4MDgzIiwicm9sZV9pZCI6Im9yZ19hZG1pbiIsImV4cCI6MTczMDk4MzEyOSwib3JnX2lkIjoib3JnXzRiYWFjbHZxUklJTEl2a25NdnZQIiwicHJvZmlsZV9pZCI6InByb18yOUFWY0ltVnFDYTV1UHdMMzlQWCJ9.E5ZfkG5y0tqGa_vzGXe5LTJlyljqP8tKs1T2qokRtr0' \
    --data-raw '[
        {
            "email": "new email",
            "name": "name",
            "role_id": "merchant_view_only"
        }
    ]'
    
    [
        {
            "email": "email from request",
            "is_email_sent": false,
            "password": "4724b955-bc1d-4565-bbb6-1a09b2372bfaA"
        }
    ]
  2. Sign in as the new user

    curl --location 'http://localhost:8080/user/v2/signin' \
    --header 'Content-Type: application/json' \
    --data-raw '{
        "email": "email used in invite",
        "password": "password from invite API response"
    }'
    
    {
        "token": "TOTP SPT",
        "token_type": "totp"
    }
  3. Terminate 2FA (This API should give reset password SPT)

    curl --location 'http://localhost:8080/user/2fa/terminate?skip_two_factor_auth=true' \
    --header 'Authorization: TOTP SPT' \
    
    {
        "token": "Force set password SPT",
        "token_type": "force_set_password"
    }

Checklist

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

@ThisIsMani ThisIsMani added C-bug Category: Bug S-waiting-on-review Status: This PR has been implemented and needs to be reviewed A-users Area: Users labels Nov 5, 2024
@ThisIsMani ThisIsMani self-assigned this Nov 5, 2024
@ThisIsMani ThisIsMani requested a review from a team as a code owner November 5, 2024 13:01
Copy link

semanticdiff-com bot commented Nov 5, 2024

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/types/domain/user.rs  44% smaller

@SanchithHegde SanchithHegde merged commit b43033c into main Nov 7, 2024
14 of 17 checks passed
@SanchithHegde SanchithHegde deleted the force-password-non-email branch November 7, 2024 10:37
@SanchithHegde SanchithHegde removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-users Area: Users C-bug Category: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(users): Force users to reset password on first login for non-email flow
5 participants