Issue:
Bug: refactor: use single purpose token and auth for accept invite



- use single purpose JWT auth and single purpose token for accept invite
- remove user without merchant JWT auth and user auth token

Pull request description:
## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [ ] Bugfix
- [ ] New feature
- [ ] Enhancement
- [x] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
- Use single purpose JWT auth and single purpose token for accept invite
- Remove user without merchant JWT auth and user auth token

### 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
closes [#4497](https://github.com/juspay/hyperswitch/issues/4497)


## How did you test it?
- Enable email feature flag
- Signup/ singin 
- Invite a new user from multiple accounts
- Sign in to newly created user
- The response should be merchant select, then do accept invite, it will give dashboard entry response.


<img width="1267" alt="Screenshot 2024-04-29 at 9 23 52 PM" src="https://github.com/juspay/hyperswitch/assets/64925866/190180a5-732c-484b-8ab0-420e96060c9d">

Current and expected behaviour of accept invite should remain same!
```curl
curl --location 'http://localhost:8080/user/user/invite/accept' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer JWT' \
--data '{
    "merchant_ids": [
         "merchant_id1",
         "merchant_id2",
         "merchant_id3"
    ],
    "need_dashboard_entry_response": true
}'
```
If any of the `merchant_id` status is `active`, then you will be getting the following response.
```
{
    "token": "JWT with merchant_id, user_id, user_role",
    "merchant_id": "merchant_id",
    "name": "user name",
    "email": "user email",
    "verification_days_left": null,
    "user_role": "user role"
}
```
If `need_dashboard_entry_response` is `false` or not sent, then the response will be 200 OK.

## 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


Testing:
- Enable email feature flag
- Signup/ singin 
- Invite a new user from multiple accounts
- Sign in to newly created user
- The response should be merchant select, then do accept invite, it will give dashboard entry response.


<img width="1267" alt="Screenshot 2024-04-29 at 9 23 52 PM" src="https://github.com/juspay/hyperswitch/assets/64925866/190180a5-732c-484b-8ab0-420e96060c9d">

Current and expected behaviour of accept invite should remain same!
```curl
curl --location 'http://localhost:8080/user/user/invite/accept' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer JWT' \
--data '{
    "merchant_ids": [
         "merchant_id1",
         "merchant_id2",
         "merchant_id3"
    ],
    "need_dashboard_entry_response": true
}'
```
If any of the `merchant_id` status is `active`, then you will be getting the following response.
```
{
    "token": "JWT with merchant_id, user_id, user_role",
    "merchant_id": "merchant_id",
    "name": "user name",
    "email": "user email",
    "verification_days_left": null,
    "user_role": "user role"
}
```
If `need_dashboard_entry_response` is `false` or not sent, then the response will be 200 OK.

Patch:
diff --git a/crates/router/src/core/user_role.rs b/crates/router/src/core/user_role.rs
index b8399251530..3f913b88a3f 100644
--- a/crates/router/src/core/user_role.rs
+++ b/crates/router/src/core/user_role.rs
@@ -170,7 +170,7 @@ pub async fn transfer_org_ownership(
 
 pub async fn accept_invitation(
     state: AppState,
-    user_token: auth::UserWithoutMerchantFromToken,
+    user_token: auth::UserFromSinglePurposeToken,
     req: user_role_api::AcceptInvitationRequest,
     _req_state: ReqState,
 ) -> UserResponse<user_api::DashboardEntryResponse> {
diff --git a/crates/router/src/routes/user_role.rs b/crates/router/src/routes/user_role.rs
index 7ffcc8d09df..7247c858f4d 100644
--- a/crates/router/src/routes/user_role.rs
+++ b/crates/router/src/routes/user_role.rs
@@ -214,7 +214,7 @@ pub async fn accept_invitation(
         &req,
         payload,
         user_role_core::accept_invitation,
-        &auth::UserWithoutMerchantJWTAuth,
+        &auth::SinglePurposeJWTAuth(auth::Purpose::AcceptInvite),
         api_locking::LockAction::NotApplicable,
     ))
     .await
diff --git a/crates/router/src/services/authentication.rs b/crates/router/src/services/authentication.rs
index 8652f51451a..c49ad81d919 100644
--- a/crates/router/src/services/authentication.rs
+++ b/crates/router/src/services/authentication.rs
@@ -149,28 +149,6 @@ impl SinglePurposeToken {
     }
 }
 
-// TODO: This has to be removed once single purpose token is used as a intermediate token
-#[derive(Clone, Debug)]
-pub struct UserWithoutMerchantFromToken {
-    pub user_id: String,
-}
-
-#[derive(serde::Serialize, serde::Deserialize)]
-pub struct UserAuthToken {
-    pub user_id: String,
-    pub exp: u64,
-}
-
-#[cfg(feature = "olap")]
-impl UserAuthToken {
-    pub async fn new_token(user_id: String, settings: &Settings) -> UserResult<String> {
-        let exp_duration = std::time::Duration::from_secs(consts::JWT_TOKEN_TIME_IN_SECS);
-        let exp = jwt::generate_exp(exp_duration)?.as_secs();
-        let token_payload = Self { user_id, exp };
-        jwt::generate_jwt(&token_payload, settings).await
-    }
-}
-
 #[derive(serde::Serialize, serde::Deserialize)]
 pub struct AuthToken {
     pub user_id: String,
@@ -330,37 +308,6 @@ where
     }
 }
 
-#[derive(Debug)]
-pub struct UserWithoutMerchantJWTAuth;
-
-#[cfg(feature = "olap")]
-#[async_trait]
-impl<A> AuthenticateAndFetch<UserWithoutMerchantFromToken, A> for UserWithoutMerchantJWTAuth
-where
-    A: AppStateInfo + Sync,
-{
-    async fn authenticate_and_fetch(
-        &self,
-        request_headers: &HeaderMap,
-        state: &A,
-    ) -> RouterResult<(UserWithoutMerchantFromToken, AuthenticationType)> {
-        let payload = parse_jwt_payload::<A, UserAuthToken>(request_headers, state).await?;
-        if payload.check_in_blacklist(state).await? {
-            return Err(errors::ApiErrorResponse::InvalidJwtToken.into());
-        }
-
-        Ok((
-            UserWithoutMerchantFromToken {
-                user_id: payload.user_id.clone(),
-            },
-            AuthenticationType::UserJwt {
-                user_id: payload.user_id,
-            },
-        ))
-    }
-}
-
-#[allow(dead_code)]
 #[derive(Debug)]
 pub(crate) struct SinglePurposeJWTAuth(pub Purpose);
 
diff --git a/crates/router/src/services/authentication/blacklist.rs b/crates/router/src/services/authentication/blacklist.rs
index b2f63f4927e..bc11ee19089 100644
--- a/crates/router/src/services/authentication/blacklist.rs
+++ b/crates/router/src/services/authentication/blacklist.rs
@@ -5,7 +5,7 @@ use common_utils::date_time;
 use error_stack::ResultExt;
 use redis_interface::RedisConnectionPool;
 
-use super::{AuthToken, SinglePurposeToken, UserAuthToken};
+use super::{AuthToken, SinglePurposeToken};
 #[cfg(feature = "email")]
 use crate::consts::{EMAIL_TOKEN_BLACKLIST_PREFIX, EMAIL_TOKEN_TIME_IN_SECS};
 use crate::{
@@ -154,16 +154,6 @@ impl BlackList for AuthToken {
     }
 }
 
-#[async_trait::async_trait]
-impl BlackList for UserAuthToken {
-    async fn check_in_blacklist<A>(&self, state: &A) -> RouterResult<bool>
-    where
-        A: AppStateInfo + Sync,
-    {
-        check_user_in_blacklist(state, &self.user_id, self.exp).await
-    }
-}
-
 #[async_trait::async_trait]
 impl BlackList for SinglePurposeToken {
     async fn check_in_blacklist<A>(&self, state: &A) -> RouterResult<bool>
diff --git a/crates/router/src/types/domain/user.rs b/crates/router/src/types/domain/user.rs
index 46f8e1340e5..fab02df88ba 100644
--- a/crates/router/src/types/domain/user.rs
+++ b/crates/router/src/types/domain/user.rs
@@ -910,8 +910,9 @@ impl SignInWithMultipleRolesStrategy {
             user_api::MerchantSelectResponse {
                 name: self.user.get_name(),
                 email: self.user.get_email(),
-                token: auth::UserAuthToken::new_token(
+                token: auth::SinglePurposeToken::new_token(
                     self.user.get_user_id().to_string(),
+                    auth::Purpose::AcceptInvite,
                     &state.conf,
                 )
                 .await?