From 3c9ba78a066bb721b005c3c0aca6ef582480b8a7 Mon Sep 17 00:00:00 2001 From: PARK BYUNG JUN Date: Tue, 16 Aug 2022 06:08:49 +0000 Subject: [PATCH] update_member is changed --- src/services/member/service.rs | 49 +++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/src/services/member/service.rs b/src/services/member/service.rs index a5a32b2..0e3f893 100644 --- a/src/services/member/service.rs +++ b/src/services/member/service.rs @@ -324,10 +324,10 @@ impl Service<'_> { if let Some(a) = request.bank_account { let bank_id = uuid::Uuid::from_str(a.bank_id.as_str()).map_err(|e| { bcr::error::rpc::Error::InvalidParams(bcr::error::rpc::InvalidParams { - message: "invalid bank_id param".to_string(), + message: "invalid bank_account.bank_id param".to_string(), detail: bcr::error::rpc::InvalidParamsDetail { location: "request".to_string(), - param: "bank_id".to_string(), + param: "bank_account.bank_id".to_string(), value: a.bank_id.clone(), error_type: bcr::error::rpc::InvalidParamsType::Required, message: e.to_string(), @@ -335,13 +335,41 @@ impl Service<'_> { }) })?; + if a.exchange_password.trim().eq("") { + return Err(bcr::error::rpc::Error::InvalidParams( + bcr::error::rpc::InvalidParams { + message: "invalid bank_account.exchange_password param".to_string(), + detail: bcr::error::rpc::InvalidParamsDetail { + location: "request".to_string(), + param: "bank_account.exchange_password".to_string(), + value: a.exchange_password, + error_type: bcr::error::rpc::InvalidParamsType::Required, + message: "bank_account.exchange_password is required".to_string(), + }, + }, + )); + } + + let exchange_password_hash = argon2::hash_encoded( + a.exchange_password.as_bytes(), + self.password_salt.as_bytes(), + &self.argon2_config, + ) + .map_err(|e| { + bcr::error::rpc::Error::Server(bcr::error::rpc::Server { + code: bpr::protobuf::rpc::Error::SERVER_00, + message: format!("server {}", e), + data: None, + }) + })?; + let new_member_bank_account = repositories::member_bank_account::models::NewMemberBankAccount { member_id: m.id, bank_id, name: a.name, account_number: a.account_number, - exchange_password: a.exchange_password, + exchange_password: exchange_password_hash, memo: None, }; self @@ -1069,12 +1097,25 @@ impl Service<'_> { }) })?; + let exchange_password_hash = argon2::hash_encoded( + a.exchange_password.as_bytes(), + self.password_salt.as_bytes(), + &self.argon2_config, + ) + .map_err(|e| { + bcr::error::rpc::Error::Server(bcr::error::rpc::Server { + code: bpr::protobuf::rpc::Error::SERVER_00, + message: format!("server {}", e), + data: None, + }) + })?; + let modify_member_bank_account = repositories::member_bank_account::models::ModifyMemberBankAccount { bank_id, name: a.name, account_number: a.account_number, - exchange_password: a.exchange_password, + exchange_password: exchange_password_hash, memo: None, }; self