feat: handle inhibit_login in /register

This commit is contained in:
timokoesters 2020-07-30 20:49:29 +02:00
parent acc7b15981
commit 0616acbde6
No known key found for this signature in database
GPG Key ID: 24DA7517711A2BA4
1 changed files with 22 additions and 13 deletions

View File

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