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

This commit is contained in:
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},
};
use serde_json::{json, value::RawValue};
use serde_json::json;
const GUEST_NAME_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");
// UIAA
let uiaainfo = UiaaInfo {
let mut uiaainfo = UiaaInfo {
flows: vec![AuthFlow {
stages: vec!["m.login.password".to_owned()],
}],
completed: Vec::new(),
params: Default::default(),
session: Some(utils::random_string(SESSION_ID_LENGTH)),
session: None,
auth_error: None,
};
@ -2931,6 +2931,7 @@ pub fn delete_device_route(
}
// Success!
} else {
uiaainfo.session = Some(utils::random_string(SESSION_ID_LENGTH));
db.uiaa.create(&user_id, &device_id, &uiaainfo).unwrap();
return MatrixResult(Err(UiaaResponse::AuthResponse(uiaainfo)));
}

View File

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