From 7c2144c6d7fd19dd933aac3dc0d30ffa30dee80a Mon Sep 17 00:00:00 2001 From: CapsizeGlimmer <> Date: Sat, 4 Jul 2020 16:41:05 -0400 Subject: [PATCH 1/3] Implement /logout/all --- src/client_server.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/client_server.rs b/src/client_server.rs index cde8bf57..f34dc60b 100644 --- a/src/client_server.rs +++ b/src/client_server.rs @@ -45,7 +45,7 @@ use ruma::{ read_marker::set_read_marker, redact::redact_event, room::{self, create_room}, - session::{get_login_types, login, logout}, + session::{get_login_types, login, logout, logout_all}, state::{ create_state_event_for_empty_key, create_state_event_for_key, get_state_events, get_state_events_for_empty_key, get_state_events_for_key, @@ -305,6 +305,22 @@ pub fn logout_route( Ok(logout::Response.into()) } +#[post("/_matrix/client/r0/logout/all", data = "")] +pub fn logout_all_route( + db: State<'_, Database>, + body: Ruma, +) -> ConduitResult { + let user_id = body.user_id.as_ref().expect("user is authenticated"); + + for device_id in db.users.all_device_ids(user_id) { + if let Ok(device_id) = device_id { + db.users.remove_device(&user_id, &device_id)?; + } + } + + Ok(logout_all::Response.into()) +} + #[post("/_matrix/client/r0/account/password", data = "")] pub fn change_password_route( db: State<'_, Database>, From 76aa44ead334d33d155f7094d7e147c8322ed2ac Mon Sep 17 00:00:00 2001 From: CapsizeGlimmer <> Date: Sun, 5 Jul 2020 02:35:19 -0400 Subject: [PATCH 2/3] Add logout/all route to main --- src/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.rs b/src/main.rs index f94df501..47b840f5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,6 +29,7 @@ fn setup_rocket() -> rocket::Rocket { client_server::get_login_route, client_server::login_route, client_server::logout_route, + client_server::logout_all_route, client_server::change_password_route, client_server::deactivate_route, client_server::get_capabilities_route, From 3a8efaeafa6c4fa9178673cf2938dcafbe1e16c5 Mon Sep 17 00:00:00 2001 From: CapsizeGlimmer <> Date: Tue, 7 Jul 2020 23:09:29 -0400 Subject: [PATCH 3/3] Whitelist logout all --- sytest/sytest-whitelist | 1 + 1 file changed, 1 insertion(+) diff --git a/sytest/sytest-whitelist b/sytest/sytest-whitelist index 3642c44e..9012346f 100644 --- a/sytest/sytest-whitelist +++ b/sytest/sytest-whitelist @@ -65,3 +65,4 @@ User in shared private room does appear in user directory User in dir while user still shares private rooms POST /rooms/:room_id/ban can ban a user Alternative server names do not cause a routing loop +Can logout all devices