From 0616acbde61b3da3594af0e24b916bb722fee2d5 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Thu, 30 Jul 2020 20:49:29 +0200 Subject: [PATCH] feat: handle inhibit_login in /register --- src/client_server/account.rs | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/client_server/account.rs b/src/client_server/account.rs index bfb768a..8764446 100644 --- a/src/client_server/account.rs +++ b/src/client_server/account.rs @@ -121,6 +121,28 @@ pub fn register_route( // Create user db.users.create(&user_id, &password)?; + // Initial data + db.account_data.update( + None, + &user_id, + EventType::PushRules, + &ruma::events::push_rules::PushRulesEvent { + content: ruma::events::push_rules::PushRulesEventContent { + global: crate::push_rules::default_pushrules(&user_id), + }, + }, + &db.globals, + )?; + + if body.inhibit_login { + return Ok(register::Response { + access_token: None, + user_id, + device_id: None, + } + .into()); + } + // Generate new device id if the user didn't specify one let device_id = body .device_id @@ -138,19 +160,6 @@ pub fn register_route( body.initial_device_display_name.clone(), )?; - // Initial data - db.account_data.update( - None, - &user_id, - EventType::PushRules, - &ruma::events::push_rules::PushRulesEvent { - content: ruma::events::push_rules::PushRulesEventContent { - global: crate::push_rules::default_pushrules(&user_id), - }, - }, - &db.globals, - )?; - Ok(register::Response { access_token: Some(token), user_id,