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 profile level invites #5793

Merged
merged 8 commits into from
Sep 4, 2024
Merged

Conversation

ThisIsMani
Copy link
Contributor

@ThisIsMani ThisIsMani commented Sep 4, 2024

Type of Change

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

Description

  • Removed preferred_merchant_id from update user API.
  • Invites will work at profile level as well.
  • Handle internal users in list APIs
    • Org List for internal users will throw error.
    • Merchant list will list merchants.
    • Profile list will list profiles.
  • New API for accept invite and merchant select is created which takes entity as request.
  • Email token will now have a entity instead of 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

Closes #5792

How did you test it?

All the following APIs should work without any issues.

  • Invite multiple

  • Accept invite from email

  • Accept invite

  • Merchant select

  • List orgs for user will throw the following error

{
    "error": {
        "type": "invalid_request",
        "message": "User Role Operation Not Supported",
        "code": "UR_23"
    }
}

New APIs
Accept Invite (works with JWT Token)

curl --location 'http://localhost:8080/user/user/invite/accept/v2' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '[
    {
        "entity_id": "merchant_id",
        "entity_type": "merchant"
    }
]'

Response: 200 OK

Accept Invite (works with Merchant Select SPT)

curl --location 'http://localhost:8080/user/user/invite/accept/v2/pre_auth' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '[
    {
        "entity_id": "merchant_id",
        "entity_type": "merchant"
    }
]'

Response:

{
    "token": "token",
    "token_type": "user_info"
}

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-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 Sep 4, 2024
@ThisIsMani ThisIsMani self-assigned this Sep 4, 2024
@ThisIsMani ThisIsMani requested review from a team as code owners September 4, 2024 10:51
Copy link

semanticdiff-com bot commented Sep 4, 2024

Review changes with SemanticDiff.

Analyzed 17 of 19 files.

Overall, the semantic diff is 27% smaller than the GitHub diff.

Filename Status
migrations/2024-09-01-094614_remove-preferred-merchant-from-users/down.sql Unsupported file format
migrations/2024-09-01-094614_remove-preferred-merchant-from-users/up.sql Unsupported file format
✔️ crates/router_env/src/logger/types.rs Analyzed
✔️ crates/router/src/utils/user_role.rs Analyzed
✔️ crates/router/src/types/domain/user.rs Analyzed
✔️ crates/router/src/types/domain/user/decision_manager.rs 28.39% smaller
✔️ crates/router/src/services/email/types.rs 1.05% smaller
✔️ crates/router/src/routes/app.rs 35.12% smaller
✔️ crates/router/src/routes/lock_utils.rs 33.86% smaller
✔️ crates/router/src/routes/user_role.rs Analyzed
✔️ crates/router/src/db/user.rs 52.63% smaller
✔️ crates/router/src/core/user.rs 37.28% smaller
✔️ crates/router/src/core/user_role.rs 11.73% smaller
✔️ crates/diesel_models/src/schema.rs Analyzed
✔️ crates/diesel_models/src/schema_v2.rs Analyzed
✔️ crates/diesel_models/src/user.rs 35.71% smaller
✔️ crates/diesel_models/src/user_role.rs 58.88% smaller
✔️ crates/api_models/src/user.rs Analyzed
✔️ crates/api_models/src/user_role.rs Analyzed

@hyperswitch-bot hyperswitch-bot bot added the M-database-changes Metadata: This PR involves database schema changes label Sep 4, 2024
crates/diesel_models/src/user_role.rs Outdated Show resolved Hide resolved
crates/diesel_models/src/user_role.rs Outdated Show resolved Hide resolved
crates/router/src/core/user.rs Show resolved Hide resolved
crates/router/src/types/domain/user.rs Outdated Show resolved Hide resolved
crates/router/src/core/user.rs Outdated Show resolved Hide resolved
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.

above comments

@likhinbopanna likhinbopanna added this pull request to the merge queue Sep 4, 2024
Merged via the queue into main with commit 28e7a7f Sep 4, 2024
17 of 18 checks passed
@likhinbopanna likhinbopanna deleted the user-misc-api-changes branch September 4, 2024 15:22
pixincreate added a commit that referenced this pull request Sep 5, 2024
* 'main' of github.com:juspay/hyperswitch:
  feat(customer_v2): Add customer V2 delete api (#5518)
  chore(version): 2024.09.05.0
  feat(user_roles): get user role details (#5777)
  feat(users): Add profile level invites (#5793)
  refactor(router): profile based routes for payouts (#5794)
  Feat(connector): [Fiuu] Add Card Flows (#5786)
  fix(cypress): fix fiservemea configs for cypress (#5772)
  fix(cypress): `api_key` check in cypress (#5787)
  feat(payment_methods_v2): Implemented Diesel and Domain models for v2 (#5700)
  fix(payout): query for getting a list of active payout IDs (#5771)
  refactor(router): remove admin v2 intermediate features (#5780)
  feat(revert): populate payment method details in payments response (#5785)
  chore(version): 2024.09.04.0
  fix(connector): skip 3DS in `network_transaction_id` flow for cybersource (#5781)
  refactor(euclid): check the authenticity of profile_id being used (#5647)
  feat(analytics): refactor and introduce analytics APIs to accommodate OrgLevel, MerchantLevel and ProfileLevel authentication (#5729)
  fix(router): make customer details None in the `Psync` flow if the customer is deleted (#5732)
  feat(connector): [DEUTSCHE] Add template code (#5774)
  chore(version): 2024.09.03.1
  fix(router): send post message to window.parent instead of window.top in external 3ds flow (#5778)
@SanchithHegde SanchithHegde removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Sep 8, 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 M-database-changes Metadata: This PR involves database schema changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(users): Add profile level invites
6 participants