Merge branch '139-restrict-usernames' into 'develop'

Resolve "Allow restricting allowed usernames"

Closes #139

See merge request funkwhale/funkwhale!107
merge-requests/154/head
Eliot Berriot 2018-03-24 19:33:38 +00:00
commit 952407d173
3 zmienionych plików z 27 dodań i 0 usunięć

Wyświetl plik

@ -385,3 +385,12 @@ CSRF_USE_SESSIONS = True
# Playlist settings
PLAYLISTS_MAX_TRACKS = env.int('PLAYLISTS_MAX_TRACKS', default=250)
ACCOUNT_USERNAME_BLACKLIST = [
'funkwhale',
'root',
'admin',
'owner',
'superuser',
'staff',
] + env.list('ACCOUNT_USERNAME_BLACKLIST', default=[])

Wyświetl plik

@ -23,6 +23,23 @@ def test_can_create_user_via_api(preferences, client, db):
assert u.username == 'test1'
def test_can_restrict_usernames(settings, preferences, db, client):
url = reverse('rest_register')
preferences['users__registration_enabled'] = True
settings.USERNAME_BLACKLIST = ['funkwhale']
data = {
'username': 'funkwhale',
'email': 'contact@funkwhale.io',
'password1': 'testtest',
'password2': 'testtest',
}
response = client.post(url, data)
assert response.status_code == 400
assert 'username' in response.data
def test_can_disable_registration_view(preferences, client, db):
url = reverse('rest_register')
data = {

Wyświetl plik

@ -0,0 +1 @@
We now restrict some usernames from being used during signup (#139)