Bug: fix(users): make id option in auth select



The id the request body of auth select should be option. It is because list will be empty for hyperswitch authentication method.
diff --git a/crates/api_models/src/user.rs b/crates/api_models/src/user.rs
index 66d4986129a..43b476c9f67 100644
--- a/crates/api_models/src/user.rs
+++ b/crates/api_models/src/user.rs
@@ -377,5 +377,5 @@ pub struct AuthIdQueryParam {
 
 #[derive(Debug, serde::Deserialize, serde::Serialize)]
 pub struct AuthSelectRequest {
-    pub id: String,
+    pub id: Option<String>,
 }
diff --git a/crates/router/src/core/user.rs b/crates/router/src/core/user.rs
index 952b74f5797..49993f3873a 100644
--- a/crates/router/src/core/user.rs
+++ b/crates/router/src/core/user.rs
@@ -2306,21 +2306,38 @@ pub async fn terminate_auth_select(
         .change_context(UserErrors::InternalServerError)?
         .into();
 
-    let user_authentication_method = state
-        .store
-        .get_user_authentication_method_by_id(&req.id)
-        .await
-        .to_not_found_response(UserErrors::InvalidUserAuthMethodOperation)?;
+    if let Some(id) = &req.id {
+        let user_authentication_method = state
+            .store
+            .get_user_authentication_method_by_id(id)
+            .await
+            .to_not_found_response(UserErrors::InvalidUserAuthMethodOperation)?;
 
-    let current_flow = domain::CurrentFlow::new(user_token, domain::SPTFlow::AuthSelect.into())?;
-    let mut next_flow = current_flow.next(user_from_db.clone(), &state).await?;
+        let current_flow =
+            domain::CurrentFlow::new(user_token, domain::SPTFlow::AuthSelect.into())?;
+        let mut next_flow = current_flow.next(user_from_db.clone(), &state).await?;
 
-    // Skip SSO if continue with password(TOTP)
-    if next_flow.get_flow() == domain::UserFlow::SPTFlow(domain::SPTFlow::SSO)
-        && !utils::user::is_sso_auth_type(&user_authentication_method.auth_type)
-    {
-        next_flow = next_flow.skip(user_from_db, &state).await?;
+        // Skip SSO if continue with password(TOTP)
+        if next_flow.get_flow() == domain::UserFlow::SPTFlow(domain::SPTFlow::SSO)
+            && !utils::user::is_sso_auth_type(&user_authentication_method.auth_type)
+        {
+            next_flow = next_flow.skip(user_from_db, &state).await?;
+        }
+        let token = next_flow.get_token(&state).await?;
+
+        return auth::cookies::set_cookie_response(
+            user_api::TokenResponse {
+                token: token.clone(),
+                token_type: next_flow.get_flow().into(),
+            },
+            token,
+        );
     }
+
+    // Giving totp token for hyperswtich users when no id is present in the request body
+    let current_flow = domain::CurrentFlow::new(user_token, domain::SPTFlow::AuthSelect.into())?;
+    let mut next_flow = current_flow.next(user_from_db.clone(), &state).await?;
+    next_flow = next_flow.skip(user_from_db, &state).await?;
     let token = next_flow.get_token(&state).await?;
 
     auth::cookies::set_cookie_response(

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

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

## Description
Make id option in auth select. If no id is passed the response should give totp 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 [#5212](https://github.com/juspay/hyperswitch/issues/5212)

## How did you test it?
request:
```
curl --location 'http://localhost:8080/user/auth/select' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiYjJkNjMxZDUtMGQzMi00Y2IxLTg2MTQtNWVlNWI2MDczYTVkIiwicHVycG9zZSI6ImF1dGhfc2VsZWN0Iiwib3JpZ2luIjoiYWNjZXB0X2ludml0YXRpb25fZnJvbV9lbWFpbCIsInBhdGgiOltdLCJleHAiOjE4MTk1ODQ1NDN9._vo2f5SpbKFcpNipvLqbJTsEJ5YwSdL__3Igg7yU4-4' \
--header 'Content-Type: application/json' \
--data '{
    
}
'
```
Response:
```
{
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiYjJkNjMxZDUtMGQzMi00Y2IxLTg2MTQtNWVlNWI2MDczYTVkIiwicHVycG9zZSI6InRvdHAiLCJvcmlnaW4iOiJhY2NlcHRfaW52aXRhdGlvbl9mcm9tX2VtYWlsIiwicGF0aCI6WyJhdXRoX3NlbGVjdCJdLCJleHAiOjE3MjAyNzYzNzh9.PiMJfzzYsNLyxUyRnBvgwKTmOgAvte1M_wU2ZBSswik",
    "token_type": "totp"
}
```


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