本文整理汇总了Python中allauth.account.adapter.DefaultAccountAdapter方法的典型用法代码示例。如果您正苦于以下问题:Python adapter.DefaultAccountAdapter方法的具体用法?Python adapter.DefaultAccountAdapter怎么用?Python adapter.DefaultAccountAdapter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类allauth.account.adapter
的用法示例。
在下文中一共展示了adapter.DefaultAccountAdapter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_pre_authenticate_fails
# 需要导入模块: from allauth.account import adapter [as 别名]
# 或者: from allauth.account.adapter import DefaultAccountAdapter [as 别名]
def test_pre_authenticate_fails(self):
UserFactory.create(username='john_snow', password='Winteriscoming!')
credentials = {'username': 'john_snow', 'password': 'knowsnothing'}
request = self.client.get(
reverse('account:login'),
{'login': 'john_snow', 'password': 'knowsnothing'})
cache_key = all_auth()._get_login_attempts_cache_key(
request, **credentials)
data = []
dt = timezone.now()
data.append(time.mktime(dt.timetuple()))
cache.set(cache_key, data, ACCOUNT_LOGIN_ATTEMPTS_TIMEOUT)
with pytest.raises(ValidationError):
a().pre_authenticate(request, **credentials)
# fake a user waiting 2 seconds
dt = timezone.now() - timedelta(seconds=2)
data.append(time.mktime(dt.timetuple()))
cache.set(cache_key, data, ACCOUNT_LOGIN_ATTEMPTS_TIMEOUT)
a().pre_authenticate(request, **credentials)
示例2: test_pre_authenticate_maxes_out
# 需要导入模块: from allauth.account import adapter [as 别名]
# 或者: from allauth.account.adapter import DefaultAccountAdapter [as 别名]
def test_pre_authenticate_maxes_out(self):
UserFactory.create(username='john_snow', password='Winteriscoming!')
credentials = {'username': 'john_snow', 'password': 'knowsnothing'}
request = self.client.get(
reverse('account:login'),
{'login': 'john_snow', 'password': 'knowsnothing'})
cache_key = all_auth()._get_login_attempts_cache_key(
request, **credentials)
data = [None] * 1000
dt = timezone.now()
data.append(time.mktime(dt.timetuple()))
cache.set(cache_key, data, ACCOUNT_LOGIN_ATTEMPTS_TIMEOUT)
with pytest.raises(ValidationError):
a().pre_authenticate(request, **credentials)
dt = timezone.now() - timedelta(seconds=ACCOUNT_LOGIN_ATTEMPTS_TIMEOUT)
data.append(time.mktime(dt.timetuple()))
cache.set(cache_key, data, ACCOUNT_LOGIN_ATTEMPTS_TIMEOUT)
a().pre_authenticate(request, **credentials)