diff --git a/src/core/user.rs b/src/core/user.rs index 26aa165..dcf6d4f 100644 --- a/src/core/user.rs +++ b/src/core/user.rs @@ -354,7 +354,7 @@ impl User { /// Get BIP32 address from site address /// /// Return: BIP32 auth address - fn get_auth_address(&mut self, address: &str, create: bool) -> Option { + pub fn get_auth_address(&mut self, address: &str, create: bool) -> Option { let auth_pair = self.get_auth_pair(address, create)?; Some(auth_pair.auth_address) } diff --git a/src/plugins/site_server/handlers/users.rs b/src/plugins/site_server/handlers/users.rs index 4f31bb2..ee05567 100644 --- a/src/plugins/site_server/handlers/users.rs +++ b/src/plugins/site_server/handlers/users.rs @@ -61,11 +61,14 @@ impl Handler for UserController { } } -#[derive(Message, Deserialize)] +#[derive(Message, Deserialize, Clone)] #[rtype(result = "Result")] pub struct UserCertAddRequest { #[serde(default)] + #[serde(skip_deserializing)] pub user_addr: String, + #[serde(skip_deserializing)] + pub site_addr: String, pub domain: String, pub auth_type: String, pub auth_user_name: String, @@ -81,12 +84,13 @@ impl Handler for UserController { address => self.get_user_mut(address), }; if let Some(user) = user { + let auth_address = user.get_auth_address(&msg.site_addr, false).unwrap(); user.add_cert( + &auth_address, &msg.domain, &msg.auth_type, &msg.auth_user_name, &msg.cert, - &msg.cert, ) } else { Err(Error::UserNotFound)