fix up v1, and improve errors

This commit is contained in:
Matthew Hodgson 2018-01-19 00:53:58 +00:00
parent 0af58f14ee
commit 9d332e0f79
4 changed files with 65 additions and 20 deletions

View file

@ -15,6 +15,7 @@
"""Contains functions for registering clients."""
import logging
import re
from twisted.internet import defer
@ -293,7 +294,7 @@ class RegistrationHandler(BaseHandler):
"""
for c in threepidCreds:
logger.info("validating theeepidcred sid %s on id server %s",
logger.info("validating threepidcred sid %s on id server %s",
c['sid'], c['idServer'])
try:
identity_handler = self.hs.get_handlers().identity_handler
@ -307,6 +308,16 @@ 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"
)
@defer.inlineCallbacks
def bind_emails(self, user_id, threepidCreds):
"""Links emails with a user ID and informs an identity server.