From ed0b6174dccfbcf06626fa39f844b7254577cd8b Mon Sep 17 00:00:00 2001 From: Mani Chandra Dulam Date: Mon, 4 Dec 2023 14:05:15 +0530 Subject: [PATCH] refactor: make get_dashboard_entry_response function take onwership of user and user_role --- crates/router/src/core/user.rs | 4 ++-- crates/router/src/utils/user.rs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/router/src/core/user.rs b/crates/router/src/core/user.rs index 8d9323623690..c868530f81af 100644 --- a/crates/router/src/core/user.rs +++ b/crates/router/src/core/user.rs @@ -94,7 +94,7 @@ pub async fn signup( let token = utils::user::generate_jwt_auth_token(state, &user_from_db, &user_role).await?; Ok(ApplicationResponse::Json( - utils::user::get_dashboard_entry_response(&user_from_db, &user_role, token), + utils::user::get_dashboard_entry_response(user_from_db, user_role, token), )) } @@ -121,7 +121,7 @@ pub async fn signin( let token = utils::user::generate_jwt_auth_token(state, &user_from_db, &user_role).await?; Ok(ApplicationResponse::Json( - utils::user::get_dashboard_entry_response(&user_from_db, &user_role, token), + utils::user::get_dashboard_entry_response(user_from_db, user_role, token), )) } diff --git a/crates/router/src/utils/user.rs b/crates/router/src/utils/user.rs index a37c17df60f6..0403d9b453d0 100644 --- a/crates/router/src/utils/user.rs +++ b/crates/router/src/utils/user.rs @@ -105,17 +105,17 @@ pub async fn generate_jwt_auth_token_with_custom_merchant_id( } pub fn get_dashboard_entry_response( - user: &UserFromStorage, - user_role: &UserRole, + user: UserFromStorage, + user_role: UserRole, token: Secret, ) -> user_api::DashboardEntryResponse { user_api::DashboardEntryResponse { - merchant_id: user_role.merchant_id.clone(), + merchant_id: user_role.merchant_id, token, name: user.get_name(), email: user.get_email(), user_id: user.get_user_id().to_string(), verification_days_left: None, - user_role: user_role.role_id.clone(), + user_role: user_role.role_id, } }