mirror of
https://github.com/girlbossceo/conduwuit.git
synced 2024-11-27 02:45:27 +00:00
forbid guest users from registering if no real admin user exists
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
01a8f6323d
commit
6664259e64
|
@ -98,6 +98,15 @@ pub async fn register_route(body: Ruma<register::v3::Request>) -> Result<registe
|
|||
));
|
||||
}
|
||||
|
||||
// forbid guests from registering if there is not a real admin user yet. give generic user error.
|
||||
if is_guest && services().users.count()? < 2 {
|
||||
warn!("Guest account attempted to register before a real admin user has been registered, rejecting registration. Guest's initial device name: {:?}", body.initial_device_display_name);
|
||||
return Err(Error::BadRequest(
|
||||
ErrorKind::Forbidden,
|
||||
"Registration temporarily disabled.",
|
||||
));
|
||||
}
|
||||
|
||||
let user_id = match (&body.username, is_guest) {
|
||||
(Some(username), false) => {
|
||||
let proposed_user_id = UserId::parse_with_server_name(
|
||||
|
|
Loading…
Reference in a new issue