Check users in our table aren't on a different domain to the one we're configured with to try & fix SYN-266

This commit is contained in:
David Baker 2015-04-24 18:11:21 +01:00
parent f46eee838a
commit a7b51f4539
2 changed files with 37 additions and 0 deletions

View file

@ -144,3 +144,21 @@ class RegistrationStore(SQLBaseStore):
return rows[0]
raise StoreError(404, "Token not found.")
@defer.inlineCallbacks
def all_users_on_domain(self, domain):
res = yield self.runInteraction(
"all_users_on_domain",
self._all_users_on_domain_txn,
domain
)
defer.returnValue(res)
def _all_users_on_domain_txn(self, txn, domain):
sql = "SELECT COUNT(*) FROM users WHERE name NOT LIKE ?"
pat = "%:"+domain
cursor = txn.execute(sql, (pat,))
num_not_matching = cursor.fetchall()[0][0]
if num_not_matching == 0:
return True
return False