Skip to content

Commit

Permalink
refactor: add email cfg flags
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisIsMani committed Dec 4, 2023
1 parent e7137a9 commit 48a9393
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 10 additions & 7 deletions crates/router/src/core/user.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use api_models::user as user_api;
use diesel_models::{enums::UserStatus, user as storage_user};
use error_stack::{IntoReport, ResultExt};
#[cfg(feature = "email")]
use error_stack::IntoReport;
use error_stack::ResultExt;
use masking::ExposeInterface;
#[cfg(feature = "email")]
use router_env::env;
#[cfg(feature = "email")]
use router_env::logger;
Expand All @@ -21,6 +24,7 @@ pub mod dashboard_metadata;
#[cfg(feature = "dummy_connector")]
pub mod sample_data;

#[cfg(feature = "email")]
pub async fn signup_with_merchant_id(
state: AppState,
request: user_api::SignUpWithMerchantIdRequest,
Expand Down Expand Up @@ -89,9 +93,9 @@ pub async fn signup(
.await?;
let token = utils::user::generate_jwt_auth_token(state, &user_from_db, &user_role).await?;

return Ok(ApplicationResponse::Json(
Ok(ApplicationResponse::Json(
utils::user::get_dashboard_entry_response(&user_from_db, &user_role, token),
));
))
}

pub async fn signin(
Expand All @@ -116,9 +120,9 @@ pub async fn signin(
let user_role = user_from_db.get_role_from_db(state.clone()).await?;
let token = utils::user::generate_jwt_auth_token(state, &user_from_db, &user_role).await?;

return Ok(ApplicationResponse::Json(
Ok(ApplicationResponse::Json(
utils::user::get_dashboard_entry_response(&user_from_db, &user_role, token),
));
))
}

#[cfg(feature = "email")]
Expand Down Expand Up @@ -379,8 +383,7 @@ pub async fn switch_merchant_id(
&user_role,
request.merchant_id.clone(),
)
.await?
.into();
.await?;

Ok(ApplicationResponse::Json(
user_api::SwitchMerchantResponse {
Expand Down
2 changes: 2 additions & 0 deletions crates/router/src/routes/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::{
utils::user::dashboard_metadata::{parse_string_to_enums, set_ip_address_if_required},
};

#[cfg(feature = "email")]
pub async fn user_signup_with_merchant_id(
state: web::Data<AppState>,
http_req: HttpRequest,
Expand Down Expand Up @@ -76,6 +77,7 @@ pub async fn user_signin(
.await
}

#[cfg(feature = "email")]
pub async fn user_connect_account(
state: web::Data<AppState>,
http_req: HttpRequest,
Expand Down

0 comments on commit 48a9393

Please sign in to comment.