Bug: refactor: fix auth select flow for default users



When no `id` is passed to auth_select request is should consider default case for user authentication method and give `totp` as the next SPT.
diff --git a/crates/router/src/core/user.rs b/crates/router/src/core/user.rs
index 49993f3873a..2abcb5ea78b 100644
--- a/crates/router/src/core/user.rs
+++ b/crates/router/src/core/user.rs
@@ -27,6 +27,7 @@ use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
 use crate::services::email::types as email_types;
 use crate::{
     consts,
+    db::domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
     routes::{app::ReqState, SessionState},
     services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
     types::{domain, transformers::ForeignInto},
@@ -2306,38 +2307,25 @@ pub async fn terminate_auth_select(
         .change_context(UserErrors::InternalServerError)?
         .into();
 
-    if let Some(id) = &req.id {
-        let user_authentication_method = state
+    let user_authentication_method = if let Some(id) = &req.id {
+        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?;
-
-        // 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,
-        );
-    }
+            .to_not_found_response(UserErrors::InvalidUserAuthMethodOperation)?
+    } else {
+        DEFAULT_USER_AUTH_METHOD.clone()
+    };
 
-    // 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?;
+
+    // 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?;
 
     auth::cookies::set_cookie_response(
diff --git a/crates/router/src/types/domain/user.rs b/crates/router/src/types/domain/user.rs
index 4c48c21204b..d5100c89c19 100644
--- a/crates/router/src/types/domain/user.rs
+++ b/crates/router/src/types/domain/user.rs
@@ -37,6 +37,7 @@ use crate::{
 pub mod dashboard_metadata;
 pub mod decision_manager;
 pub use decision_manager::*;
+pub mod user_authentication_method;
 
 use super::{types as domain_types, UserKeyStore};
 
diff --git a/crates/router/src/types/domain/user/user_authentication_method.rs b/crates/router/src/types/domain/user/user_authentication_method.rs
new file mode 100644
index 00000000000..570e144961a
--- /dev/null
+++ b/crates/router/src/types/domain/user/user_authentication_method.rs
@@ -0,0 +1,17 @@
+use common_enums::{Owner, UserAuthType};
+use diesel_models::UserAuthenticationMethod;
+use once_cell::sync::Lazy;
+
+pub static DEFAULT_USER_AUTH_METHOD: Lazy<UserAuthenticationMethod> =
+    Lazy::new(|| UserAuthenticationMethod {
+        id: String::from("hyperswitch_default"),
+        auth_id: String::from("hyperswitch"),
+        owner_id: String::from("hyperswitch"),
+        owner_type: Owner::Tenant,
+        auth_type: UserAuthType::Password,
+        private_config: None,
+        public_config: None,
+        allow_signup: true,
+        created_at: common_utils::date_time::now(),
+        last_modified_at: common_utils::date_time::now(),
+    });

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

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

## Description
- Populated the User Authentication Method data statically for default users
- Auth select should give next flow as `totp` when no `id` is passed

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


## How did you test it?
For no id present in the reqeust:
```
curl --location 'http://localhost:8080/user/auth/select' \
--header 'Authorization: Bearer SPT' \
--header 'Content-Type: application/json' \
--data '{
    
}`
```
Respnse:
```
{
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiYjJkNjMxZDUtMGQzMi00Y2IxLTg2MTQtNWVlNWI2MDczYTVkIiwicHVycG9zZSI6InRvdHAiLCJvcmlnaW4iOiJhY2NlcHRfaW52aXRhdGlvbl9mcm9tX2VtYWlsIiwicGF0aCI6WyJhdXRoX3NlbGVjdCJdLCJleHAiOjE3MjA2OTE2OTl9.5-tVDAdKytWrzc17N77uMARuJJqyX0OohT-LybY-xn4",
    "token_type": "totp"
}
```
For id which is not present in the user authentication method
```
curl --location 'http://localhost:8080/user/auth/select' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiYjJkNjMxZDUtMGQzMi00Y2IxLTg2MTQtNWVlNWI2MDczYTVkIiwicHVycG9zZSI6ImF1dGhfc2VsZWN0Iiwib3JpZ2luIjoiYWNjZXB0X2ludml0YXRpb25fZnJvbV9lbWFpbCIsInBhdGgiOltdLCJleHAiOjE4MTk1ODQ1NDN9._vo2f5SpbKFcpNipvLqbJTsEJ5YwSdL__3Igg7yU4-4' \
--header 'Content-Type: application/json' \
--data '{
    "id": "not_present"
}`
```
Respnse will be bad request:
```
{
    "error": {
        "type": "invalid_request",
        "message": "Invalid user auth method operation",
        "code": "UR_44"
    }
}
```
For Some id for which user auth method is present the in response we will get token type accodingly:
```
curl --location 'http://localhost:8080/user/auth/select' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiYjJkNjMxZDUtMGQzMi00Y2IxLTg2MTQtNWVlNWI2MDczYTVkIiwicHVycG9zZSI6ImF1dGhfc2VsZWN0Iiwib3JpZ2luIjoiYWNjZXB0X2ludml0YXRpb25fZnJvbV9lbWFpbCIsInBhdGgiOltdLCJleHAiOjE4MTk1ODQ1NDN9._vo2f5SpbKFcpNipvLqbJTsEJ5YwSdL__3Igg7yU4-4' \
--header 'Content-Type: application/json' \
--data '{
    "id": "f20742d2-f1b8-4dad-8b2d-cf8fe6d457eb"
}
'
```
Response:
```
{
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiYjJkNjMxZDUtMGQzMi00Y2IxLTg2MTQtNWVlNWI2MDczYTVkIiwicHVycG9zZSI6InNzbyIsIm9yaWdpbiI6ImFjY2VwdF9pbnZpdGF0aW9uX2Zyb21fZW1haWwiLCJwYXRoIjpbImF1dGhfc2VsZWN0Il0sImV4cCI6MTcyMDY5MTg3Nn0.SNmkULnpkYNtxuyJ3BE7d1J7fzVZx0pg1LTsBFwFx0o",
    "token_type": "sso"
}
```

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