summary refs log tree commit diff
path: root/synapse/handlers/register.py
diff options
context:
space:
mode:
authorNeil Johnson <neil@matrix.org>2018-10-12 18:17:36 +0100
committerNeil Johnson <neil@matrix.org>2018-10-12 18:17:36 +0100
commita2bfb778c8a2a91bdff1a5824571d91f4f4536d3 (patch)
tree7bf855c7c1cc9bef67efbbec611070958ad4ee44 /synapse/handlers/register.py
parentMerge branch 'develop' into matthew/autocreate_autojoin (diff)
downloadsynapse-a2bfb778c8a2a91bdff1a5824571d91f4f4536d3.tar.xz
improve auto room join logic, comments and tests
Diffstat (limited to 'synapse/handlers/register.py')
-rw-r--r--synapse/handlers/register.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/synapse/handlers/register.py b/synapse/handlers/register.py
index 01cf7ab58e..2b269ab692 100644
--- a/synapse/handlers/register.py
+++ b/synapse/handlers/register.py
@@ -26,6 +26,7 @@ from synapse.api.errors import (
     RegistrationError,
     SynapseError,
 )
+from synapse.config._base import ConfigError
 from synapse.http.client import CaptchaServerHttpClient
 from synapse.types import RoomAlias, RoomID, UserID, create_requester
 from synapse.util.async_helpers import Linearizer
@@ -222,14 +223,19 @@ class RegistrationHandler(BaseHandler):
         fake_requester = create_requester(user_id)
 
         # try to create the room if we're the first user on the server
+        should_auto_create_rooms = False
         if self.hs.config.autocreate_auto_join_rooms:
             count = yield self.store.count_all_users()
-            auto_create_rooms = count == 1
+            should_auto_create_rooms = count == 1
 
         for r in self.hs.config.auto_join_rooms:
             try:
-                if auto_create_rooms and RoomAlias.is_valid(r):
+                if should_auto_create_rooms:
                     room_creation_handler = self.hs.get_room_creation_handler()
+                    if self.hs.hostname != RoomAlias.from_string(r).domain:
+                        raise ConfigError(
+                            'Cannot create room alias %s, it does not match server domain'
+                        )
                     # create room expects the localpart of the room alias
                     room_alias_localpart = RoomAlias.from_string(r).localpart
                     yield room_creation_handler.create_room(
@@ -531,7 +537,6 @@ class RegistrationHandler(BaseHandler):
 
     @defer.inlineCallbacks
     def _join_user_to_room(self, requester, room_identifier):
-
         room_id = None
         room_member_handler = self.hs.get_room_member_handler()
         if RoomID.is_valid(room_identifier):