Skip to content

Conversation

ThisIsMani
Copy link
Contributor

@ThisIsMani ThisIsMani commented Jun 3, 2024

Type of Change

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

Description

After this PR, Home API will send the details about the user's 2FA, specifically weather user has completed 2FA setup and number of recovery codes left for him.

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 #4848

How did you test it?

  1. Home API

    curl --location 'http://localhost:8080/user' \
    --header 'Authorization: Bearer Login Token'
    
    {
        "merchant_id": "company_name",
        "name": "name",
        "email": "email",
        "verification_days_left": null,
        "role_id": "org_admin",
        "org_id": "org_lbZlm2cx4j2LgVo7bUwq",
        "is_two_factor_auth_setup": true,
        "recovery_codes_left": 8
    }
  2. Signout

    1. Hit Signout API

      curl --location --request POST 'http://localhost:8080/user/signout' \
      --header 'Content-Type: application/json' \
      --header 'Authorization: Bearer Login Token'
      

      200 OK

    2. Signin with the same user again

      curl --location 'http://localhost:8080/user/v2/signin' \
      --header 'Content-Type: application/json' \
      --data-raw '{
          "email": "email",
          "password": "password"
      }'
      
      {
          "flow_type": "dashboard_entry",
          "token": "Login Token",
          "merchant_id": "company_name",
          "name": "name",
          "email": "email",
          "verification_days_left": null,
          "user_role": "org_admin"
      }
      
    3. Take the token from the above response and hit 2FA status API

      curl --location 'http://localhost:8080/user/2fa' \
      --header 'Authorization: Bearer Login Token'
      
      {
          "totp": false,
          "recovery_code": false
      }
      

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 S-waiting-on-review Status: This PR has been implemented and needs to be reviewed C-refactor Category: Refactor A-users Area: Users labels Jun 3, 2024
@ThisIsMani ThisIsMani self-assigned this Jun 3, 2024
@ThisIsMani ThisIsMani requested a review from a team as a code owner June 3, 2024 10:06
racnan
racnan previously approved these changes Jun 3, 2024
Comment on lines +168 to +169
pub is_two_factor_auth_setup: bool,
pub recovery_codes_left: Option<usize>,
Copy link
Contributor

Choose a reason for hiding this comment

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

recovery_codes_left: Some(_) represents is_two_factor_auth_setup: true.
Lets try to simplify if possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will be done once we remove totp_status from users.

@racnan
Copy link
Contributor

racnan commented Jun 3, 2024

Add test case for signout changes as well

apoorvdixit88
apoorvdixit88 previously approved these changes Jun 3, 2024
@ThisIsMani ThisIsMani dismissed stale reviews from apoorvdixit88 and racnan via faf1ad9 June 3, 2024 13:01
apoorvdixit88
apoorvdixit88 previously approved these changes Jun 3, 2024
racnan
racnan previously approved these changes Jun 3, 2024
@ThisIsMani ThisIsMani dismissed stale reviews from racnan and apoorvdixit88 via 8768108 June 3, 2024 13:09
@Gnanasundari24 Gnanasundari24 enabled auto-merge June 3, 2024 13:53
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Jun 3, 2024
Merged via the queue into main with commit d242850 Jun 3, 2024
@Gnanasundari24 Gnanasundari24 deleted the home-singout branch June 3, 2024 14:25
pixincreate added a commit that referenced this pull request Jun 4, 2024
…atus_pt

* 'main' of github.com:juspay/hyperswitch:
  chore(version): 2024.06.04.0
  fix: include client_version and client_source in retried payments (#4826)
  refactor(users): Changes for Home and Signout APIs for TOTP Redis flows (#4851)
  feat(users): Create config for TOTP Issuer (#4776)
  feat(multitenancy): add support for multitenancy and handle the same in router, producer, consumer, drainer and analytics (#4630)
  feat(connector): [AUTHORIZEDOTNET] Support payment_method_id in recurring mandate payment (#4841)
  refactor(connector): airwallex convert init payment to preprocessing (#4842)
  feat(router): send `three_ds_requestor_url` in authentication_response for external 3ds flow (#4828)
  feat(consolidated-kafka-events): add consolidated kafka payment events (#4798)
  refactor(connector): [Klarna] Add shipping Address in Klarna Session and Payment Request (#4836)
  fix(connector): make few fields optional in struct NetceteraErrorDetails (#4827)
  chore(cypress): remove logs that expose `globalState` (#4844)
pixincreate added a commit that referenced this pull request Jun 4, 2024
* 'main' of github.com:juspay/hyperswitch:
  feat(cypress): Add service level testing for Payouts (#4744)
  feat(auth): Create and use `SinglePurposeOrLoginTokenAuth` (#4830)
  refactor(connector): [Adyen] handle redirection error response (#4862)
  refactor(api_models): rename Card struct for payouts to avoid overrides in auto generated open API spec (#4861)
  chore(version): 2024.06.04.1
  fix(connector): [Adyen]add required fields for afterpay clearpay (#4858)
  chore(version): 2024.06.04.0
  fix: include client_version and client_source in retried payments (#4826)
  refactor(users): Changes for Home and Signout APIs for TOTP Redis flows (#4851)
  feat(users): Create config for TOTP Issuer (#4776)
  feat(multitenancy): add support for multitenancy and handle the same in router, producer, consumer, drainer and analytics (#4630)
  feat(connector): [AUTHORIZEDOTNET] Support payment_method_id in recurring mandate payment (#4841)
  refactor(connector): airwallex convert init payment to preprocessing (#4842)
  feat(router): send `three_ds_requestor_url` in authentication_response for external 3ds flow (#4828)
  feat(consolidated-kafka-events): add consolidated kafka payment events (#4798)
@SanchithHegde SanchithHegde removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Jun 9, 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-refactor Category: Refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

refactor: Home and Sign out API changes for 2FA Phase - II
5 participants