Skip to content

Commit

Permalink
fix: UserCertAddRequest handler
Browse files Browse the repository at this point in the history
  • Loading branch information
canewsin committed Jan 20, 2024
1 parent 0980b6c commit ef2cdb5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/core/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> {
pub fn get_auth_address(&mut self, address: &str, create: bool) -> Option<String> {
let auth_pair = self.get_auth_pair(address, create)?;
Some(auth_pair.auth_address)
}
Expand Down
8 changes: 6 additions & 2 deletions src/plugins/site_server/handlers/users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,14 @@ impl Handler<UserSetSiteCertRequest> for UserController {
}
}

#[derive(Message, Deserialize)]
#[derive(Message, Deserialize, Clone)]
#[rtype(result = "Result<bool, Error>")]
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,
Expand All @@ -81,12 +84,13 @@ impl Handler<UserCertAddRequest> 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)
Expand Down

0 comments on commit ef2cdb5

Please sign in to comment.