Merge pull request 'fix' (#115) from uiaa into master

next
Timo Kösters 2020-06-08 15:19:48 +02:00
commit 80935c5826
2 changed files with 7 additions and 14 deletions

View File

@ -58,7 +58,7 @@ use ruma::{
}, },
identifiers::{RoomAliasId, RoomId, RoomVersionId, UserId}, identifiers::{RoomAliasId, RoomId, RoomVersionId, UserId},
}; };
use serde_json::{json, value::RawValue}; use serde_json::json;
const GUEST_NAME_LENGTH: usize = 10; const GUEST_NAME_LENGTH: usize = 10;
const DEVICE_ID_LENGTH: usize = 10; const DEVICE_ID_LENGTH: usize = 10;
@ -2904,13 +2904,13 @@ pub fn delete_device_route(
let device_id = body.device_id.as_ref().expect("user is authenticated"); let device_id = body.device_id.as_ref().expect("user is authenticated");
// UIAA // UIAA
let uiaainfo = UiaaInfo { let mut uiaainfo = UiaaInfo {
flows: vec![AuthFlow { flows: vec![AuthFlow {
stages: vec!["m.login.password".to_owned()], stages: vec!["m.login.password".to_owned()],
}], }],
completed: Vec::new(), completed: Vec::new(),
params: Default::default(), params: Default::default(),
session: Some(utils::random_string(SESSION_ID_LENGTH)), session: None,
auth_error: None, auth_error: None,
}; };
@ -2931,6 +2931,7 @@ pub fn delete_device_route(
} }
// Success! // Success!
} else { } else {
uiaainfo.session = Some(utils::random_string(SESSION_ID_LENGTH));
db.uiaa.create(&user_id, &device_id, &uiaainfo).unwrap(); db.uiaa.create(&user_id, &device_id, &uiaainfo).unwrap();
return MatrixResult(Err(UiaaResponse::AuthResponse(uiaainfo))); return MatrixResult(Err(UiaaResponse::AuthResponse(uiaainfo)));
} }

View File

@ -1,20 +1,12 @@
use crate::{utils, Error, Result}; use crate::{Error, Result};
use js_int::UInt;
use log::debug; use log::debug;
use ruma::{ use ruma::{
api::client::{ api::client::{
error::ErrorKind, error::ErrorKind,
r0::{ r0::uiaa::{AuthData, UiaaInfo},
device::Device,
keys::{AlgorithmAndDeviceId, DeviceKeys, KeyAlgorithm, OneTimeKey},
uiaa::{AuthData, AuthFlow, UiaaInfo, UiaaResponse},
}, },
},
events::{to_device::AnyToDeviceEvent, EventJson, EventType},
identifiers::UserId, identifiers::UserId,
}; };
use serde_json::value::RawValue;
use std::{collections::BTreeMap, convert::TryFrom, time::SystemTime};
pub struct Uiaa { pub struct Uiaa {
pub(super) userdeviceid_uiaainfo: sled::Tree, // User-interactive authentication pub(super) userdeviceid_uiaainfo: sled::Tree, // User-interactive authentication
@ -44,7 +36,7 @@ impl Uiaa {
let mut uiaainfo = session let mut uiaainfo = session
.as_ref() .as_ref()
.map(|session| { .map(|session| {
Ok::<_, Error>(self.get_uiaa_session(&user_id, &"".to_owned(), session)?) Ok::<_, Error>(self.get_uiaa_session(&user_id, &device_id, session)?)
}) })
.unwrap_or(Ok(uiaainfo.clone()))?; .unwrap_or(Ok(uiaainfo.clone()))?;