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

feat(users): Add preferred_merchant_id column and update user details API #3373

Merged
merged 5 commits into from
Jan 18, 2024

Conversation

ThisIsMani
Copy link
Contributor

@ThisIsMani ThisIsMani commented Jan 17, 2024

Type of Change

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

Description

  • This PR adds a new column in users table called preferred_merchant_id. preferred_merchant_id will be used at the time of signin to directly use that merchant_id when user has access to multiple merchant accounts.
  • This PR adds a new API which enables users to update their name and preferred merchant id.

Additional Changes

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

Motivation and Context

To support the highlighted flow in the following diagram.
Note: This PR doesn't have the actual changes of the flow, but has few required changes to make the highlighted flow possible.

flowchart TD
    A["Connect Account"] -- Email --> B{"User Exists"}
    B -- No --> C["Create new \n Org \n Merchant \n User \n User Role"]
    C --> D["Send Verify Email"]
    D --> E["Verify Email Token"]
    B -- Yes --> D
    E --> H{"Is there\n any perferred \nmerchant"}
    F -- ==0 --> I{{"Send list of \nmerchants which\n user has access to\n along with an\n intermediate token"}}
    F -- >1 --> G[Select the first role with active status]
    subgraph Preferred Merchant
	    H -- Yes --> M["Send the token \nwith that merchant_id"]
    end
    H -- No --> F{"How many \n active merchants\n does user have \naccess to"}
    I -- merchant_ids, \nintermediate_token --> O["Accept Invite"]
    O --> P["Change status to active"]
    P --> G
    G --> M
    K["Sign In"] -- Email, Password --> H
Loading

How did you test it?

Postman.

curl --location 'http://localhost:8080/user/update' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer JWT' \
--data '{
    "name": "user name", // Optional
    "preferred_merchant_id": "merchant_id" // Optional, user should have access to this merchant_id
}'

If the api is successful, the db will be updated and the response will be 200 OK.

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
  • I added a CHANGELOG entry if applicable

@ThisIsMani ThisIsMani added C-feature Category: Feature request or enhancement S-waiting-on-review Status: This PR has been implemented and needs to be reviewed A-users Area: Users labels Jan 17, 2024
@ThisIsMani ThisIsMani self-assigned this Jan 17, 2024
@ThisIsMani ThisIsMani requested review from a team as code owners January 17, 2024 12:44
@ThisIsMani ThisIsMani linked an issue Jan 17, 2024 that may be closed by this pull request
@ThisIsMani ThisIsMani changed the title feat(users): Add preferred merchant id column and update user details API feat(users): Add preferred_merchant_id column and update user details API Jan 17, 2024
apoorvdixit88
apoorvdixit88 previously approved these changes Jan 18, 2024
Copy link
Contributor

@apoorvdixit88 apoorvdixit88 left a comment

Choose a reason for hiding this comment

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

LGTM

racnan
racnan previously approved these changes Jan 18, 2024
Copy link
Contributor

@racnan racnan left a comment

Choose a reason for hiding this comment

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

Minor thing other than that LGTM.

crates/router/src/core/user.rs Outdated Show resolved Hide resolved
@ThisIsMani ThisIsMani dismissed stale reviews from racnan and apoorvdixit88 via 5df28ff January 18, 2024 12:01
@preetamrevankar preetamrevankar added this pull request to the merge queue Jan 18, 2024
Merged via the queue into main with commit 862a1b5 Jan 18, 2024
9 checks passed
@preetamrevankar preetamrevankar deleted the user-update branch January 18, 2024 13:28
pixincreate added a commit that referenced this pull request Jan 18, 2024
* 'main' of github.com:juspay/hyperswitch:
  feat(users): Added get role from jwt api (#3385)
  feat(users): Add `preferred_merchant_id` column and update user details API (#3373)
  chore(version): 2024.01.18.1
  refactor(core): add locker config to enable or disable locker  (#3352)
  fix(connector): [Cashtocode] update amount from i64 to f64 in webhook payload (#3382)
  fix(metrics): Add TASKS_ADDED_COUNT and TASKS_RESET_COUNT metrics in router scheduler flow (#3189)
  fix(connector): Trustpay zen error mapping (#3255)
  fix(user): fetch profile_id for sample data (#3358)
  refactor(connector): [Volt] Refactor Payments and Refunds Webhooks (#3377)
  chore(version): 2024.01.18.0
@Gnanasundari24 Gnanasundari24 added the M-database-changes Metadata: This PR involves database schema changes label Jan 19, 2024
@Gnanasundari24 Gnanasundari24 removed the M-database-changes Metadata: This PR involves database schema changes label Jan 19, 2024
@SanchithHegde SanchithHegde removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Jan 21, 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-feature Category: Feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: update user details api
8 participants