mirror of
https://github.com/jazzband/django-defender.git
synced 2026-03-16 22:10:32 +00:00
Allow usernames with plus signs in unblock view (#77)
This fixes bug #GH76 where an exception like
```
Reverse for 'defender_unblock_username_view' with arguments '(u'user+test@domain.tld',)' and keyword arguments '{}' not found. 1 pattern(s) tried: [u'admin/defender/blocks/username/(?P[A-Za-z0-9-._@]+)/unblock$']
```
was raised when trying to access the `/admin/defender/blocks/` URL when a user with a plus sign had been locked out.
This commit is contained in:
parent
c4f3a61036
commit
69db1cfb70
3 changed files with 14 additions and 2 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
from django.conf.urls import url, include
|
from django.conf.urls import url, include
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
|
from .urls import urlpatterns as original_urlpatterns
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^admin/', include(admin.site.urls)),
|
url(r'^admin/', include(admin.site.urls)),
|
||||||
]
|
] + original_urlpatterns
|
||||||
|
|
|
||||||
|
|
@ -532,6 +532,16 @@ class AccessAttemptTest(DefenderTestCase):
|
||||||
from .admin import AccessAttemptAdmin
|
from .admin import AccessAttemptAdmin
|
||||||
AccessAttemptAdmin
|
AccessAttemptAdmin
|
||||||
|
|
||||||
|
def test_unblock_view_user_with_plus(self):
|
||||||
|
"""
|
||||||
|
There is an available admin view for unblocking a user
|
||||||
|
with a plus sign in the username.
|
||||||
|
|
||||||
|
Regression test for #GH76.
|
||||||
|
"""
|
||||||
|
reverse('defender_unblock_username_view',
|
||||||
|
kwargs={'username': 'user+test@test.tld'})
|
||||||
|
|
||||||
def test_decorator_middleware(self):
|
def test_decorator_middleware(self):
|
||||||
# because watch_login is called twice in this test (once by the
|
# because watch_login is called twice in this test (once by the
|
||||||
# middleware and once by the decorator) we have half as many attempts
|
# middleware and once by the decorator) we have half as many attempts
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ urlpatterns = [
|
||||||
name="defender_blocks_view"),
|
name="defender_blocks_view"),
|
||||||
url(r'^blocks/ip/(?P<ip_address>[A-Za-z0-9-._]+)/unblock$', unblock_ip_view,
|
url(r'^blocks/ip/(?P<ip_address>[A-Za-z0-9-._]+)/unblock$', unblock_ip_view,
|
||||||
name="defender_unblock_ip_view"),
|
name="defender_unblock_ip_view"),
|
||||||
url(r'^blocks/username/(?P<username>[A-Za-z0-9-._@]+)/unblock$',
|
url(r'^blocks/username/(?P<username>[A-Za-z0-9-._@\+]+)/unblock$',
|
||||||
unblock_username_view,
|
unblock_username_view,
|
||||||
name="defender_unblock_username_view"),
|
name="defender_unblock_username_view"),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue