Merge pull request 'feat: handle inhibit_login in /register' (#173) from inhibit-login into master

Reviewed-on: https://git.koesters.xyz/timo/conduit/pulls/173
next
Timo Kösters 2020-07-30 22:21:09 +02:00
commit 5cfda2f5d3
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,