mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-25 19:15:51 +03:00
bug fixes
This commit is contained in:
parent
e10830e976
commit
886be75ad1
5 changed files with 10 additions and 27 deletions
|
@ -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):
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -452,12 +452,8 @@ class AuthTestCase(unittest.TestCase):
|
|||
lots_of_users = 100
|
||||
small_number_of_users = 1
|
||||
|
||||
error = AuthError(
|
||||
403, "MAU Limit Exceeded", errcode=Codes.MAU_LIMIT_EXCEEDED
|
||||
)
|
||||
|
||||
# Ensure no error thrown
|
||||
yield self.auth.check_auth_blocking(error)
|
||||
yield self.auth.check_auth_blocking()
|
||||
|
||||
self.hs.config.limit_usage_by_mau = True
|
||||
|
||||
|
@ -466,10 +462,10 @@ class AuthTestCase(unittest.TestCase):
|
|||
)
|
||||
|
||||
with self.assertRaises(AuthError):
|
||||
yield self.auth.check_auth_blocking(error)
|
||||
yield self.auth.check_auth_blocking()
|
||||
|
||||
# Ensure does not throw an error
|
||||
self.store.get_monthly_active_count = Mock(
|
||||
return_value=defer.succeed(small_number_of_users)
|
||||
)
|
||||
yield self.auth.check_auth_blocking(error)
|
||||
yield self.auth.check_auth_blocking()
|
||||
|
|
|
@ -104,7 +104,6 @@ class RegistrationTestCase(unittest.TestCase):
|
|||
self.store.get_monthly_active_count = Mock(
|
||||
return_value=defer.succeed(self.lots_of_users)
|
||||
)
|
||||
|
||||
with self.assertRaises(RegistrationError):
|
||||
yield self.handler.get_or_create_user("requester", 'b', "display_name")
|
||||
|
||||
|
|
Loading…
Reference in a new issue