Bug: bug(user): Wrong Internal user `org_id`



Currently when an internal user is being created, a new user will be created and a `user_role` with `merchant_id` as `juspay000` will also be inserted.

As the merchant `juspay000` already has a `org_id`, we should use that and insert that `org_id` in `user_role`, but currently a new `org_id` is being generated and inserted everytime when this API is hit.
diff --git a/crates/router/src/core/user.rs b/crates/router/src/core/user.rs
index cfc01afb91b..65d605b3862 100644
--- a/crates/router/src/core/user.rs
+++ b/crates/router/src/core/user.rs
@@ -1046,11 +1046,6 @@ pub async fn create_internal_user(
     state: SessionState,
     request: user_api::CreateInternalUserRequest,
 ) -> UserResponse<()> {
-    let new_user = domain::NewUser::try_from(request)?;
-
-    let mut store_user: storage_user::UserNew = new_user.clone().try_into()?;
-    store_user.set_is_verified(true);
-
     let key_store = state
         .store
         .get_merchant_key_store_by_merchant_id(
@@ -1066,7 +1061,7 @@ pub async fn create_internal_user(
             }
         })?;
 
-    state
+    let internal_merchant = state
         .store
         .find_merchant_account_by_merchant_id(
             consts::user_role::INTERNAL_USER_MERCHANT_ID,
@@ -1081,6 +1076,11 @@ pub async fn create_internal_user(
             }
         })?;
 
+    let new_user = domain::NewUser::try_from((request, internal_merchant.organization_id))?;
+
+    let mut store_user: storage_user::UserNew = new_user.clone().try_into()?;
+    store_user.set_is_verified(true);
+
     state
         .store
         .insert_user(store_user)
diff --git a/crates/router/src/types/domain/user.rs b/crates/router/src/types/domain/user.rs
index 60d75ce81d1..0ff9d651baf 100644
--- a/crates/router/src/types/domain/user.rs
+++ b/crates/router/src/types/domain/user.rs
@@ -284,9 +284,12 @@ impl From<user_api::ConnectAccountRequest> for NewUserOrganization {
     }
 }
 
-impl From<user_api::CreateInternalUserRequest> for NewUserOrganization {
-    fn from(_value: user_api::CreateInternalUserRequest) -> Self {
-        let new_organization = api_org::OrganizationNew::new(None);
+impl From<(user_api::CreateInternalUserRequest, String)> for NewUserOrganization {
+    fn from((_value, org_id): (user_api::CreateInternalUserRequest, String)) -> Self {
+        let new_organization = api_org::OrganizationNew {
+            org_id,
+            org_name: None,
+        };
         let db_organization = ForeignFrom::foreign_from(new_organization);
         Self(db_organization)
     }
@@ -457,10 +460,10 @@ impl TryFrom<user_api::SignUpWithMerchantIdRequest> for NewUserMerchant {
     }
 }
 
-impl TryFrom<user_api::CreateInternalUserRequest> for NewUserMerchant {
+impl TryFrom<(user_api::CreateInternalUserRequest, String)> for NewUserMerchant {
     type Error = error_stack::Report<UserErrors>;
 
-    fn try_from(value: user_api::CreateInternalUserRequest) -> UserResult<Self> {
+    fn try_from(value: (user_api::CreateInternalUserRequest, String)) -> UserResult<Self> {
         let merchant_id =
             MerchantId::new(consts::user_role::INTERNAL_USER_MERCHANT_ID.to_string())?;
         let new_organization = NewUserOrganization::from(value);
@@ -702,15 +705,17 @@ impl TryFrom<user_api::ConnectAccountRequest> for NewUser {
     }
 }
 
-impl TryFrom<user_api::CreateInternalUserRequest> for NewUser {
+impl TryFrom<(user_api::CreateInternalUserRequest, String)> for NewUser {
     type Error = error_stack::Report<UserErrors>;
 
-    fn try_from(value: user_api::CreateInternalUserRequest) -> UserResult<Self> {
+    fn try_from(
+        (value, org_id): (user_api::CreateInternalUserRequest, String),
+    ) -> UserResult<Self> {
         let user_id = uuid::Uuid::new_v4().to_string();
         let email = value.email.clone().try_into()?;
         let name = UserName::new(value.name.clone())?;
         let password = UserPassword::new(value.password.clone())?;
-        let new_merchant = NewUserMerchant::try_from(value)?;
+        let new_merchant = NewUserMerchant::try_from((value, org_id))?;
 
         Ok(Self {
             user_id,

## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [x] Bugfix
- [ ] New feature
- [ ] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
<!-- Describe your changes in detail -->
Internal signup will now use the `org_id` of `juspay000` and insert it in `user_roles`.

### Additional Changes

- [ ] This PR modifies the API contract
- [ ] This PR modifies the database schema
- [ ] This PR modifies application configuration/environment variables

<!--
Provide links to the files with corresponding changes.

Following are the paths where you can find config files:
1. `config`
2. `crates/router/src/configs`
3. `loadtest/config`
-->


## Motivation and Context
<!--
Why is this change required? What problem does it solve?
If it fixes an open issue, please link to the issue here.

If you don't have an issue, we'd recommend starting with one first so the PR
can focus on the implementation (unless it is an obvious bug or documentation fix
that will have little conversation).
-->
Closes #4887.

## How did you test it?
<!--
Did you write an integration/unit/API test to verify the code changes?
Or did you test this change manually (provide relevant screenshots)?
-->
```
curl --location 'http://localhost:8080/user/internal_signup' \
--header 'api-key: admin-api-key' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name" : "name",
    "email" : "email",
    "password": "password"
}'
```

In `user_roles` table, the `org_id` is the correct one as the `juspay000` merchant account. These are the queries I've used to verify.

```sql
select organization_id from merchant_account where merchant_id = 'juspay000'
```

```sql
select org_id from user_roles where merchant_id = 'juspay000'
```


In both cases, `org_id` should be same for newly created user.


## Checklist
<!-- Put an `x` in the boxes that apply -->

- [x] I formatted the code `cargo +nightly fmt --all`
- [x] I addressed lints thrown by `cargo clippy`
- [x] I reviewed the submitted code
- [ ] I added unit tests for my changes where possible
