summary refs log tree commit diff
path: root/synapse/config
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-04-30 15:04:06 +0100
committerMark Haines <mark.haines@matrix.org>2015-04-30 15:04:06 +0100
commit265f30bd3f080f11b5cf6644d293943932c592e4 (patch)
treeb2649abceb7d66c8f11d23cbe85d7d4e2f7bd62b /synapse/config
parentUse disable_registration keys if they are present (diff)
downloadsynapse-265f30bd3f080f11b5cf6644d293943932c592e4.tar.xz
Allow --enable-registration to be passed on the commandline
Diffstat (limited to 'synapse/config')
-rw-r--r--synapse/config/registration.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/synapse/config/registration.py b/synapse/config/registration.py
index 095c3d3b00..971965a5da 100644
--- a/synapse/config/registration.py
+++ b/synapse/config/registration.py
@@ -17,18 +17,18 @@ from ._base import Config
 
 from synapse.util.stringutils import random_string_with_symbols
 
-import distutils.util
+from distutils.util import strtobool
 
 
 class RegistrationConfig(Config):
 
     def read_config(self, config):
         self.disable_registration = not bool(
-            distutils.util.strtobool(str(config["enable_registration"]))
+            strtobool(str(config["enable_registration"]))
         )
         if "disable_registration" in config:
             self.disable_registration = bool(
-                distutils.util.strtobool(str(config["disable_registration"]))
+                strtobool(str(config["disable_registration"]))
             )
 
         self.registration_shared_secret = config.get("registration_shared_secret")
@@ -45,3 +45,16 @@ class RegistrationConfig(Config):
         # secret, even if registration is otherwise disabled.
         registration_shared_secret: "%(registration_shared_secret)s"
         """ % locals()
+
+    def add_arguments(self, parser):
+        reg_group = parser.add_argument_group("registration")
+        reg_group.add_argument(
+            "--enable-registration", action="store_true",
+            help="Enable registration for new users."
+        )
+
+    def read_arguments(self, args):
+        if args.enable_registration is not None:
+            self.disable_registration = not bool(
+                strtobool(str(args.enable_registration))
+            )