From f2a5d466284d20a0c815bffe22fc7e2634ed055a Mon Sep 17 00:00:00 2001 From: timokoesters Date: Mon, 8 Jun 2020 15:17:58 +0200 Subject: [PATCH] fix --- src/client_server.rs | 7 ++++--- src/database/uiaa.rs | 14 +++----------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/client_server.rs b/src/client_server.rs index 6e0c40a2..b0542044 100644 --- a/src/client_server.rs +++ b/src/client_server.rs @@ -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))); } diff --git a/src/database/uiaa.rs b/src/database/uiaa.rs index 6cd25b99..9851e841 100644 --- a/src/database/uiaa.rs +++ b/src/database/uiaa.rs @@ -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()))?;