def _is_blocked_temporarily(self, username):
num_login_attempts = self._config.defaults['authorization']['num_login_attempts']
block_for_seconds = self._config.defaults['authorization']['block_for_seconds']
self._mongo.db['block_entries'].delete_many({'timestamp': {'$lt': time() - block_for_seconds}})
block_entries = list(self._mongo.db['block_entries'].find({'username': username}))
if len(block_entries) > num_login_attempts:
return True
return False
评论列表
文章目录