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): new routes to accept invite and list merchants #4591

Merged
merged 11 commits into from
May 9, 2024

Conversation

apoorvdixit88
Copy link
Contributor

@apoorvdixit88 apoorvdixit88 commented May 8, 2024

Type of Change

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

Description

This PR:

  • adds new route to accept invite from dashboard with JWT Auth
  • adds new routes to get list of merchants to select for user, SPT Auth
  • modifies to send accept invite from email instead of set password for new user in token only flow

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

How did you test it?

To accept invite from inside dashboard

curl --location --request PUT 'http://localhost:8080/user/user/invite/accept' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer JWT' \
--data '{
    "merchant_ids": [
        "merchant_175173995"
    ]
}'

Response will be 200 Ok

To get merchant select list

curl --location 'http://localhost:8080/user/merchants_select/list' \
--header 'Authorization: Bearer JWT'

Respnse will be something like

[
    {
        "merchant_id": "merchant_1715075310",
        "merchant_name": "sd",
        "is_active": true,
        "role_id": "merchant_view_only",
        "role_name": "view_only",
        "org_id": "org_BoTucsApoZG6LeGY41hZ"
    },
    {
        "merchant_id": "merchant_1715173995",
        "merchant_name": null,
        "is_active": true,
        "role_id": "merchant_admin",
        "role_name": "admin",
        "org_id": "org_fhL0yj8FWiPhnPnGR7NM"
    }
]

For new user invitation we should send accept_invite from email not reset password email

curl --location 'http://localhost:8080/user/user/invite_multiple' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer JWT' \
--data-raw '[
    {
        "email": "test+totp@gmail.com",
        "name": "test",
        "role_id": "merchant_admin"
    }
]'

Response for email feature flag enable:

[
    {
        "email": "apoorvdixit88+ttp@gmail.com",
        "is_email_sent": true
    }
]

Also check for what email got sent in inbox.

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

@apoorvdixit88 apoorvdixit88 added C-feature Category: Feature request or enhancement S-waiting-on-review Status: This PR has been implemented and needs to be reviewed M-api-contract-changes Metadata: This PR involves API contract changes A-users Area: Users labels May 8, 2024
@apoorvdixit88 apoorvdixit88 requested review from racnan and ThisIsMani May 8, 2024 13:34
@apoorvdixit88 apoorvdixit88 self-assigned this May 8, 2024
@apoorvdixit88 apoorvdixit88 requested review from a team as code owners May 8, 2024 13:34
ThisIsMani
ThisIsMani previously approved these changes May 9, 2024
@@ -752,25 +765,36 @@ async fn handle_new_user_invitation(
})?;

let is_email_sent;
// TODO: Adding this to avoid clippy lints, is_token_only parameter to removed when TOTP flows get stablized
let _ = is_token_only;
Copy link
Contributor

Choose a reason for hiding this comment

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

😂

@@ -1230,6 +1254,39 @@ pub async fn list_merchants_for_user(
))
}

pub async fn list_merchants_to_select_for_user(
Copy link
Contributor

Choose a reason for hiding this comment

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

can have a better name

Comment on lines 1261 to 1276
let user_roles = state
.store
.list_user_roles_by_user_id(user_token.user_id.as_str())
.await
.change_context(UserErrors::InternalServerError)?;

let merchant_accounts = state
.store
.list_multiple_merchant_accounts(
user_roles
.iter()
.map(|role| role.merchant_id.clone())
.collect(),
)
.await
.change_context(UserErrors::InternalServerError)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Code repetition. Can be solved with traits.

.flatten()
.ok_or(UserErrors::MerchantIdNotFound)?;

Ok(ApplicationResponse::StatusOk)
Copy link
Contributor

Choose a reason for hiding this comment

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

use map in above instead of separate response

@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue May 9, 2024
Merged via the queue into main with commit e70d58a May 9, 2024
12 of 15 checks passed
@Gnanasundari24 Gnanasundari24 deleted the new-routes-for-accept-invite-and-switch-flow branch May 9, 2024 13:24
pixincreate added a commit that referenced this pull request May 10, 2024
…efactor

* 'main' of github.com:juspay/hyperswitch:
  chore(version): 2024.05.10.0
  fix(router): [NETCETERA] skip sending browser_information in authentication request for app device_channel (#4613)
  fix(users): Fix bugs caused by the new token only flows (#4607)
  ci(cypress): Fix card expiry for savecard flows (#4585)
  refactor(billing): store `payment_method_data_billing` for recurring payments (#4513)
  feat(users): new routes to accept invite and list merchants (#4591)
  fix(connector): [BAMBORA] Audit Fixes for Bambora (#4604)
  fix(connector): [iatapay]handle empty error response in case of 401 (#4291)
  feat(connector): [Payone] add connector template code (#4469)
  feat(users): Create API to Verify TOTP (#4597)
  chore(version): 2024.05.09.0
  chore(postman): update Postman collection files
  fix(core): drop three_dsserver_trans_id from authentication table (#4587)
  refactor(db): Add TenantId field to the KafkaStore struct (#4512)
  feat(users): Create `user_key_store` table and `begin_totp` API (#4577)
  Fix(connector): [BOA/CYBS] make rsync status optional (#4570)
  fix(users): Correct the condition for `verify_email` flow in decision manger (#4580)
@SanchithHegde SanchithHegde removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label May 12, 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-api-contract-changes Metadata: This PR involves API contract changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: new apis for accept invite and list merchant
5 participants