rewrite based on PR feedback:

* [ ] split config options into allowed_local_3pids and registrations_require_3pid
 * [ ] simplify and comment logic for picking registration flows
 * [ ] fix docstring and move check_3pid_allowed into a new util module
 * [ ] use check_3pid_allowed everywhere

@erikjohnston PTAL
This commit is contained in:
Matthew Hodgson 2018-01-19 15:33:55 +00:00
parent 9d332e0f79
commit 447f4f0d5f
7 changed files with 101 additions and 88 deletions

View file

@ -15,7 +15,6 @@
"""Contains functions for registering clients."""
import logging
import re
from twisted.internet import defer
@ -26,6 +25,7 @@ from synapse.http.client import CaptchaServerHttpClient
from synapse import types
from synapse.types import UserID
from synapse.util.async import run_on_reactor
from synapse.util.threepids import check_3pid_allowed
from ._base import BaseHandler
logger = logging.getLogger(__name__)
@ -308,15 +308,10 @@ class RegistrationHandler(BaseHandler):
logger.info("got threepid with medium '%s' and address '%s'",
threepid['medium'], threepid['address'])
for constraint in self.hs.config.registrations_require_3pid:
if (
constraint['medium'] == 'email' and
threepid['medium'] == 'email' and
re.match(constraint['pattern'], threepid['address'])
):
raise RegistrationError(
403, "Third party identifier is not allowed"
)
if not check_3pid_allowed(self.hs, threepid['medium'], threepid['address']):
raise RegistrationError(
403, "Third party identifier is not allowed"
)
@defer.inlineCallbacks
def bind_emails(self, user_id, threepidCreds):