1
0
Fork 0
mirror of https://forgejo.ellis.link/continuwuation/continuwuity.git synced 2025-09-15 17:26:58 +00:00

fix(!1014): Don't prematurely return during registration

This commit is contained in:
nexy7574 2025-09-11 17:21:20 +01:00 committed by nex
parent 81b6b3547c
commit d9d0d1a465

View file

@ -405,27 +405,34 @@ pub(crate) async fn register_route(
) )
.await?; .await?;
if (!is_guest && body.inhibit_login) // if (!is_guest && body.inhibit_login)
// || body
// .appservice_info
// .as_ref()
// .is_some_and(|appservice| appservice.registration.device_management)
// {
// return Ok(register::v3::Response {
// access_token: None,
// user_id,
// device_id: None,
// refresh_token: None,
// expires_in: None,
// });
// }
// Generate new device id if the user didn't specify one
let no_device = body.inhibit_login
|| body || body
.appservice_info .appservice_info
.as_ref() .as_ref()
.is_some_and(|appservice| appservice.registration.device_management) .is_some_and(|aps| aps.registration.device_management);
{ let (token, device) = if !no_device {
return Ok(register::v3::Response { // Don't create a device for inhibited logins
access_token: None,
user_id,
device_id: None,
refresh_token: None,
expires_in: None,
});
}
// Generate new device id if the user didn't specify one
let device_id = if is_guest { None } else { body.device_id.clone() } let device_id = if is_guest { None } else { body.device_id.clone() }
.unwrap_or_else(|| utils::random_string(DEVICE_ID_LENGTH).into()); .unwrap_or_else(|| utils::random_string(DEVICE_ID_LENGTH).into());
// Generate new token for the device // Generate new token for the device
let token = utils::random_string(TOKEN_LENGTH); let new_token = utils::random_string(TOKEN_LENGTH);
// Create device for this account // Create device for this account
services services
@ -433,13 +440,16 @@ pub(crate) async fn register_route(
.create_device( .create_device(
&user_id, &user_id,
&device_id, &device_id,
&token, &new_token,
body.initial_device_display_name.clone(), body.initial_device_display_name.clone(),
Some(client.to_string()), Some(client.to_string()),
) )
.await?; .await?;
debug_info!(%user_id, %device_id, "User account was created"); debug_info!(%user_id, %device_id, "User account was created");
(Some(new_token), Some(device_id))
} else {
(None, None)
};
let device_display_name = body.initial_device_display_name.as_deref().unwrap_or(""); let device_display_name = body.initial_device_display_name.as_deref().unwrap_or("");
@ -583,9 +593,9 @@ pub(crate) async fn register_route(
} }
Ok(register::v3::Response { Ok(register::v3::Response {
access_token: Some(token), access_token: token,
user_id, user_id,
device_id: Some(device_id), device_id: device,
refresh_token: None, refresh_token: None,
expires_in: None, expires_in: None,
}) })