bug fixed

This commit is contained in:
병준 박 2022-08-24 06:43:35 +00:00
parent 629527eebf
commit 8f4e5f4bdc
2 changed files with 25 additions and 5 deletions

View File

@ -83,6 +83,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
connection_server_broker.clone(), connection_server_broker.clone(),
queue_server_broker.clone(), queue_server_broker.clone(),
pool.clone(), pool.clone(),
password_salt.clone(),
); );
let member_bank_deposit_service = services::member_bank_deposit::service::Service::new( let member_bank_deposit_service = services::member_bank_deposit::service::Service::new(
connection_server_broker.clone(), connection_server_broker.clone(),

View File

@ -14,29 +14,32 @@ use diesel::{
use prost::Message; use prost::Message;
/// ///
pub struct Service { pub struct Service<'a> {
connection_broker: nats::asynk::Connection, connection_broker: nats::asynk::Connection,
queue_broker: String, queue_broker: String,
pool: Pool<ConnectionManager<PgConnection>>, pool: Pool<ConnectionManager<PgConnection>>,
site_repository: repositories::site::repository::Repository, site_repository: repositories::site::repository::Repository,
site_composition: compositions::site::composition::Composition, site_composition: compositions::site::composition::Composition,
member_bank_account_repository: repositories::member_bank_account::repository::Repository, member_bank_account_repository: repositories::member_bank_account::repository::Repository,
argon2_config: argon2::Config<'a>,
password_salt: String,
} }
impl std::fmt::Debug for Service { impl std::fmt::Debug for Service<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("Service of service.member.service.identity") f.debug_struct("Service of service.member.service.identity")
.finish() .finish()
} }
} }
impl Service { impl Service<'_> {
/// ///
pub fn new( pub fn new(
connection_broker: nats::asynk::Connection, connection_broker: nats::asynk::Connection,
queue_broker: String, queue_broker: String,
pool: Pool<ConnectionManager<PgConnection>>, pool: Pool<ConnectionManager<PgConnection>>,
) -> Service { password_salt: String,
) -> Service<'static> {
Service { Service {
connection_broker, connection_broker,
queue_broker, queue_broker,
@ -45,6 +48,8 @@ impl Service {
site_composition: compositions::site::composition::Composition::new(), site_composition: compositions::site::composition::Composition::new(),
member_bank_account_repository: member_bank_account_repository:
repositories::member_bank_account::repository::Repository::new(), repositories::member_bank_account::repository::Repository::new(),
argon2_config: argon2::Config::default(),
password_salt,
} }
} }
@ -794,6 +799,19 @@ impl Service {
}, },
}) })
})?; })?;
let exchange_password_hash = argon2::hash_encoded(
request.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 conn = self.pool.get().map_err(|e| { let conn = self.pool.get().map_err(|e| {
bcr::error::rpc::Error::Server(bcr::error::rpc::Server { bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
@ -803,13 +821,14 @@ impl Service {
}) })
})?; })?;
let _affected = self let _affected = self
.member_bank_account_repository .member_bank_account_repository
.update_exchange_password( .update_exchange_password(
&conn, &conn,
id, id,
&repositories::member_bank_account::models::ModifyMemberBankAccountForExchangePassword { &repositories::member_bank_account::models::ModifyMemberBankAccountForExchangePassword {
exchange_password: request.exchange_password, exchange_password: exchange_password_hash,
}, },
) )
.map_err(|e| { .map_err(|e| {