mirror of
https://gitlab.com/famedly/conduit.git
synced 2025-07-02 16:38:36 +00:00
feat: base support
This commit is contained in:
parent
139588b64c
commit
67c23d6dd4
9 changed files with 148 additions and 178 deletions
|
@ -100,6 +100,12 @@ pub async fn upload_signing_keys_route(
|
|||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
let sender_device = body.sender_device.as_ref().expect("user is authenticated");
|
||||
|
||||
let master_key = services()
|
||||
.users
|
||||
.get_master_key(Some(sender_user), sender_user, &|other| {
|
||||
sender_user == other
|
||||
})?;
|
||||
|
||||
// UIAA
|
||||
let mut uiaainfo = UiaaInfo {
|
||||
flows: vec![AuthFlow {
|
||||
|
@ -111,11 +117,15 @@ pub async fn upload_signing_keys_route(
|
|||
auth_error: None,
|
||||
};
|
||||
|
||||
let master_key = services()
|
||||
.users
|
||||
.get_master_key(None, sender_user, &|user_id| user_id == sender_user)?;
|
||||
|
||||
if let Some(auth) = &body.auth {
|
||||
if let (Some(master_key), None) = (&body.master_key, master_key) {
|
||||
services().users.add_cross_signing_keys(
|
||||
sender_user,
|
||||
master_key,
|
||||
&body.self_signing_key,
|
||||
&body.user_signing_key,
|
||||
true,
|
||||
)?;
|
||||
} else if let Some(auth) = &body.auth {
|
||||
let (worked, uiaainfo) =
|
||||
services()
|
||||
.uiaa
|
||||
|
@ -130,20 +140,10 @@ pub async fn upload_signing_keys_route(
|
|||
.uiaa
|
||||
.create(sender_user, sender_device, &uiaainfo, &json)?;
|
||||
return Err(Error::Uiaa(uiaainfo));
|
||||
} else if master_key.is_some() {
|
||||
} else {
|
||||
return Err(Error::BadRequest(ErrorKind::NotJson, "Not json."));
|
||||
}
|
||||
|
||||
if let Some(master_key) = &body.master_key {
|
||||
services().users.add_cross_signing_keys(
|
||||
sender_user,
|
||||
master_key,
|
||||
&body.self_signing_key,
|
||||
&body.user_signing_key,
|
||||
true, // notify so that other users see the new keys
|
||||
)?;
|
||||
}
|
||||
|
||||
Ok(upload_signing_keys::v3::Response {})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue