예제 #1
0
 def setUp(self):
     super(SearchViewTest, self).setUp()
     self.translation = self.component.translation_set.get(
         language_code='cs'
     )
     self.translate_url = self.translation.get_translate_url()
     self.update_fulltext_index()
     reset_rate_limit('search', address='127.0.0.1')
예제 #2
0
파일: forms.py 프로젝트: saily/weblate
    def clean(self):
        username = self.cleaned_data.get('username')
        password = self.cleaned_data.get('password')

        if username and password:
            if not check_rate_limit(self.request):
                raise forms.ValidationError(
                    _('Too many authentication attempts!')
                )
            self.user_cache = authenticate(
                username=username,
                password=password
            )
            if self.user_cache is None:
                try:
                    notify_account_activity(
                        try_get_user(username),
                        self.request,
                        'failed-auth',
                        method='Password',
                        name=username,
                    )
                except User.DoesNotExist:
                    pass
                rotate_token(self.request)
                raise forms.ValidationError(
                    self.error_messages['invalid_login'],
                    code='invalid_login',
                )
            elif not self.user_cache.is_active:
                raise forms.ValidationError(
                    self.error_messages['inactive'],
                    code='inactive',
                )
            else:
                notify_account_activity(
                    self.user_cache,
                    self.request,
                    'login',
                    method='Password',
                    name=username,
                )
            reset_rate_limit(self.request)
        return self.cleaned_data
예제 #3
0
파일: forms.py 프로젝트: daleathan/weblate
    def clean(self):
        username = self.cleaned_data.get('username')
        password = self.cleaned_data.get('password')

        if username and password:
            if not check_rate_limit('login', self.request):
                raise forms.ValidationError(
                    _('Too many authentication attempts from this location!')
                )
            self.user_cache = authenticate(
                self.request,
                username=username,
                password=password
            )
            if self.user_cache is None:
                for user in try_get_user(username, True):
                    notify_account_activity(
                        user,
                        self.request,
                        'failed-auth',
                        method=ugettext('Password'),
                        name=username,
                    )
                rotate_token(self.request)
                raise forms.ValidationError(
                    self.error_messages['invalid_login'],
                    code='invalid_login',
                )
            elif not self.user_cache.is_active:
                raise forms.ValidationError(
                    self.error_messages['inactive'],
                    code='inactive',
                )
            else:
                notify_account_activity(
                    self.user_cache,
                    self.request,
                    'login',
                    method=ugettext('Password'),
                    name=username,
                )
            reset_rate_limit('login', self.request)
        return self.cleaned_data
예제 #4
0
 def setUp(self):
     super(RegistrationTest, self).setUp()
     reset_rate_limit(address='127.0.0.1')
예제 #5
0
파일: test_views.py 프로젝트: saily/weblate
 def setUp(self):
     super(ViewTest, self).setUp()
     reset_rate_limit(address='127.0.0.1')
예제 #6
0
 def setUp(self):
     super(BaseRegistrationTest, self).setUp()
     reset_rate_limit(address='127.0.0.1')
예제 #7
0
 def setUp(self):
     # Ensure no rate limits are there
     reset_rate_limit(address='1.2.3.4')
     reset_rate_limit(address='7.8.9.0')
예제 #8
0
 def setUp(self):
     # Ensure no rate limits are there
     for address in META.values():
         reset_rate_limit(address=address)
예제 #9
0
 def setUp(self):
     super(ViewTest, self).setUp()
     reset_rate_limit('login', address='127.0.0.1')
     reset_rate_limit('message', address='127.0.0.1')
예제 #10
0
 def setUp(self):
     # Ensure no rate limits are there
     for address in META.values():
         reset_rate_limit(address=address)
예제 #11
0
 def setUp(self):
     # Ensure no rate limits are there
     reset_rate_limit('test', address='1.2.3.4')
예제 #12
0
 def setUp(self):
     super(ViewTest, self).setUp()
     reset_rate_limit('login', address='127.0.0.1')
     reset_rate_limit('message', address='127.0.0.1')
예제 #13
0
 def setUp(self):
     super(ViewTest, self).setUp()
     reset_rate_limit(address='127.0.0.1')
예제 #14
0
 def setUp(self):
     super(BaseRegistrationTest, self).setUp()
     reset_rate_limit('registration', address='127.0.0.1')
     reset_rate_limit('login', address='127.0.0.1')