Merge pull request 'Implement /logout/all' (#141) from CapsizeGlimmer/conduit:logout-all into master

Reviewed-on: https://git.koesters.xyz/timo/conduit/pulls/141
Reviewed-by: Timo Kösters <timo@koesters.xyz>
next
Timo Kösters 2020-07-09 19:21:12 +02:00
commit 8409146415
3 changed files with 19 additions and 1 deletions

View File

@ -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 = "<body>")]
pub fn logout_all_route(
db: State<'_, Database>,
body: Ruma<logout_all::Request>,
) -> ConduitResult<logout_all::Response> {
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 = "<body>")]
pub fn change_password_route(
db: State<'_, Database>,

View File

@ -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,

View File

@ -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