diff --git a/synapse/handlers/auth.py b/synapse/handlers/auth.py
index 8f9cff92e8..7ea8ce9f94 100644
--- a/synapse/handlers/auth.py
+++ b/synapse/handlers/auth.py
@@ -520,7 +520,7 @@ class AuthHandler(BaseHandler):
"""
logger.info("Logging in user %s on device %s", user_id, device_id)
access_token = yield self.issue_access_token(user_id, device_id)
- yield self._check_mau_limits()
+ yield self.auth.check_auth_blocking()
# the device *should* have been registered before we got here; however,
# it's possible we raced against a DELETE operation. The thing we
@@ -734,7 +734,7 @@ class AuthHandler(BaseHandler):
@defer.inlineCallbacks
def validate_short_term_login_token_and_get_user_id(self, login_token):
- yield self._check_mau_limits()
+ yield self.auth.check_auth_blocking()
auth_api = self.hs.get_auth()
user_id = None
try:
@@ -907,17 +907,6 @@ class AuthHandler(BaseHandler):
else:
return defer.succeed(False)
- @defer.inlineCallbacks
- def _check_mau_limits(self):
- """
- Ensure that if mau blocking is enabled that invalid users cannot
- log in.
- """
- error = AuthError(
- 403, "Monthly Active User limits exceeded", errcode=Codes.MAU_LIMIT_EXCEEDED
- )
- yield self.auth.check_auth_blocking(error)
-
@attr.s
class MacaroonGenerator(object):
diff --git a/synapse/handlers/register.py b/synapse/handlers/register.py
index 706ed8c292..8cf0a36a8f 100644
--- a/synapse/handlers/register.py
+++ b/synapse/handlers/register.py
@@ -540,7 +540,7 @@ class RegistrationHandler(BaseHandler):
Do not accept registrations if monthly active user limits exceeded
and limiting is enabled
"""
- error = RegistrationError(
- 403, "Monthly Active User limits exceeded", errcode=Codes.MAU_LIMIT_EXCEEDED
- )
- yield self.auth.check_auth_blocking(error)
+ try:
+ yield self.auth.check_auth_blocking()
+ except AuthError as e:
+ raise RegistrationError(e.code, e.message, e.errcode)
diff --git a/synapse/storage/monthly_active_users.py b/synapse/storage/monthly_active_users.py
index 6def6830d0..135837507a 100644
--- a/synapse/storage/monthly_active_users.py
+++ b/synapse/storage/monthly_active_users.py
@@ -54,7 +54,7 @@ class MonthlyActiveUsersStore(SQLBaseStore):
"""
txn.execute(sql, (self.hs.config.max_mau_value,))
- res = yield self.runInteraction("reap_monthly_active_users", _reap_users)
+ yield self.runInteraction("reap_monthly_active_users", _reap_users)
# It seems poor to invalidate the whole cache, Postgres supports
# 'Returning' which would allow me to invalidate only the
# specific users, but sqlite has no way to do this and instead
@@ -64,7 +64,6 @@ class MonthlyActiveUsersStore(SQLBaseStore):
# something about it if and when the perf becomes significant
self._user_last_seen_monthly_active.invalidate_all()
self.get_monthly_active_count.invalidate_all()
- return res
@cached(num_args=0)
def get_monthly_active_count(self):
|