add config option for guest registration, make guest registration respect allow_registration
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
f20beae8dc
commit
b0fdc1351b
3 changed files with 22 additions and 0 deletions
|
@ -86,6 +86,17 @@ pub async fn register_route(body: Ruma<register::v3::Request>) -> Result<registe
|
||||||
|
|
||||||
let is_guest = body.kind == RegistrationKind::Guest;
|
let is_guest = body.kind == RegistrationKind::Guest;
|
||||||
|
|
||||||
|
if is_guest
|
||||||
|
&& (!services().globals.allow_guest_registration()
|
||||||
|
|| !services().globals.allow_registration())
|
||||||
|
{
|
||||||
|
info!("Guest registration disabled / registration fully disabled, rejecting guest registration, initial device name: {:?}", body.initial_device_display_name);
|
||||||
|
return Err(Error::BadRequest(
|
||||||
|
ErrorKind::GuestAccessForbidden,
|
||||||
|
"Guest registration is disabled.",
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
let user_id = match (&body.username, is_guest) {
|
let user_id = match (&body.username, is_guest) {
|
||||||
(Some(username), false) => {
|
(Some(username), false) => {
|
||||||
let proposed_user_id = UserId::parse_with_server_name(
|
let proposed_user_id = UserId::parse_with_server_name(
|
||||||
|
|
|
@ -119,6 +119,9 @@ pub struct Config {
|
||||||
#[serde(default = "false_fn")]
|
#[serde(default = "false_fn")]
|
||||||
pub zstd_compression: bool,
|
pub zstd_compression: bool,
|
||||||
|
|
||||||
|
#[serde(default = "false_fn")]
|
||||||
|
pub allow_guest_registration: bool,
|
||||||
|
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub catchall: BTreeMap<String, IgnoredAny>,
|
pub catchall: BTreeMap<String, IgnoredAny>,
|
||||||
}
|
}
|
||||||
|
@ -195,6 +198,10 @@ impl fmt::Display for Config {
|
||||||
&self.max_concurrent_requests.to_string(),
|
&self.max_concurrent_requests.to_string(),
|
||||||
),
|
),
|
||||||
("Allow registration", &self.allow_registration.to_string()),
|
("Allow registration", &self.allow_registration.to_string()),
|
||||||
|
(
|
||||||
|
"Allow guest registration",
|
||||||
|
&self.allow_guest_registration.to_string(),
|
||||||
|
),
|
||||||
(
|
(
|
||||||
"Enabled lightning bolt",
|
"Enabled lightning bolt",
|
||||||
&self.enable_lightning_bolt.to_string(),
|
&self.enable_lightning_bolt.to_string(),
|
||||||
|
|
|
@ -295,6 +295,10 @@ impl Service {
|
||||||
self.config.allow_registration
|
self.config.allow_registration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn allow_guest_registration(&self) -> bool {
|
||||||
|
self.config.allow_guest_registration
|
||||||
|
}
|
||||||
|
|
||||||
pub fn allow_encryption(&self) -> bool {
|
pub fn allow_encryption(&self) -> bool {
|
||||||
self.config.allow_encryption
|
self.config.allow_encryption
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue