diff --git a/modules/client/register.cc b/modules/client/register.cc index 3e597d8be..ed1eb8f7f 100644 --- a/modules/client/register.cc +++ b/modules/client/register.cc @@ -55,6 +55,7 @@ method_post }; ircd::conf::item +IRCD_MODULE_EXPORT register_enable { { "name", "ircd.client.register.enable" }, @@ -103,6 +104,7 @@ post__register(client &client, } ircd::conf::item +IRCD_MODULE_EXPORT register_user_enable { { "name", "ircd.client.register.user.enable" }, diff --git a/modules/client/register_available.cc b/modules/client/register_available.cc index 167929eda..48c7c5ad2 100644 --- a/modules/client/register_available.cc +++ b/modules/client/register_available.cc @@ -40,10 +40,29 @@ validate_user_id "client_register", "validate_user_id" }; +mods::import> +register_enable +{ + "client_register", "register_enable" +}; + +mods::import> +register_user_enable +{ + "client_register", "register_user_enable" +}; + resource::response get__register_available(client &client, const resource::request &request) { + if(!bool(register_enable) || !bool(register_user_enable)) + throw m::error + { + http::FORBIDDEN, "M_REGISTRATION_DISABLED", + "Registration is disabled. No username is available." + }; + // The successful construction of this m::user::id implies valid // formatting otherwise an m::INVALID_MXID (400) is thrown. m::user::id::buf user_id