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(user_role): Add APIs for user roles #3013

Merged
merged 12 commits into from
Nov 30, 2023
Merged

feat(user_role): Add APIs for user roles #3013

merged 12 commits into from
Nov 30, 2023

Conversation

ThisIsMani
Copy link
Contributor

@ThisIsMani ThisIsMani commented Nov 29, 2023

Type of Change

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

Description

This PR add the following APIs:

  1. /user/internal_signup
  2. /user/switch_merchant
  3. /user/create_merchant
  4. /user/permission_info
  5. /user/user/update_role
  6. /user/role/list
  7. /user/role/{role_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

User Management.

How did you test it?

Postman.

  1. Internal User Signup
curl --location 'http://localhost:8080/user/internal_signup' \
--header 'api-key: adminapikey' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name" : "username",
    "email" : "user_email",
    "password": "password"
}'

You will get 200 OK response if api is succeeded.

  1. Switch Merchant
curl --location 'http://localhost:8080/user/switch_merchant' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer JWTToken' \
--data '{
    "merchant_id": "merchant_id that user has access to"
}'

You will get the following response if the api is succeeded

{
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiODFiNDgwZjItMTQzOS00ZDhiLWI2OWMtYjkzZjczYjM3ZDMwIiwibWVyY2hhbnRfaWQiOiJtZXJjaGFudF8xNzAwODEzNzU0Iiwicm9sZV9pZCI6ImludGVybmFsX3ZpZXdfb25seSIsImV4cCI6MTcwMTUxNzg2Mywib3JnX2lkIjoib3JnXzRxb2I5d1lpUEhJQWtiVFFIMW42In0.-BoQtV5DGlr5dd3QFYLBmJr-UXPpROGA6R5ekSI8fc4",
    "merchant_id": "merchant_1700813754",
    "name": "Deepak Venga",
    "email": "[email protected]",
    "verification_days_left": null,
    "user_role": "internal_view_only"
}
  1. Create Merchant
curl --location 'http://localhost:8080/user/create_merchant' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer JWTToken' \
--data '{
    "company_name": "Hyperswitch"
}'

You will get 200 OK response if api is succeeded.

  1. Permission Info
curl --location 'http://localhost:8080/user/permission_info' \
--header 'Authorization: Bearer JWTToken' \

You will details of all the permissions.

  1. Update User Role
curl --location 'http://localhost:8080/user/user/update_role' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer JWTToken' \
--data '{
    "user_id": "user id",
    "role_id": "any role id"
}'

You will get 200 OK response if api is succeeded.

  1. List Roles
curl --location 'http://localhost:8080/user/role/list' \
--header 'Authorization: Bearer JWTToken' \

You will get all the roles present in the application in the response.

  1. Role Info
curl --location 'http://localhost:8080/user/role/{role_id}' \
--header 'Authorization: Bearer JWTToken'

You will get the details of the role_id that is passed in the params.

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 Nov 29, 2023
@ThisIsMani ThisIsMani added this to the November 2023 Release milestone Nov 29, 2023
@ThisIsMani ThisIsMani self-assigned this Nov 29, 2023
@ThisIsMani ThisIsMani marked this pull request as ready for review November 29, 2023 13:28
@ThisIsMani ThisIsMani requested review from a team as code owners November 29, 2023 13:28
racnan
racnan previously approved these changes Nov 30, 2023
apoorvdixit88
apoorvdixit88 previously approved these changes Nov 30, 2023
@ThisIsMani ThisIsMani dismissed stale reviews from apoorvdixit88 and racnan via 835a362 November 30, 2023 12:30
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Nov 30, 2023
Merged via the queue into main with commit 3fa0bdf Nov 30, 2023
10 of 12 checks passed
@Gnanasundari24 Gnanasundari24 deleted the user-roles branch November 30, 2023 14:47
@pixincreate pixincreate removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Nov 30, 2023
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
No open projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

6 participants