Skip to content

Commit 2c699ed

Browse files
author
Matthew Fisher
committed
fix(controller): remove username length validation
This fix that was implemented in #631 was a bit hackish, and was only used because we stored the images as username/appname in the registry. The registry has a restriction where the username has to be greater than or equal to 4 in length. Now that we are not storing the images with the associated owner's username, we no longer need this restriction. reverts #631
1 parent 75aeb67 commit 2c699ed

3 files changed

Lines changed: 0 additions & 16 deletions

File tree

controller/api/exceptions.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from __future__ import unicode_literals
66

77
from rest_framework.exceptions import APIException
8-
from rest_framework import status
98

109

1110
class AbstractDeisException(APIException):
@@ -22,10 +21,3 @@ def __init__(self, detail=None):
2221

2322
class Meta:
2423
abstract = True
25-
26-
27-
class UserRegistrationException(AbstractDeisException):
28-
"""
29-
Indicates that there was a problem registering the user.
30-
"""
31-
status_code = status.HTTP_400_BAD_REQUEST

controller/api/tests/test_auth.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ def test_auth(self):
5656
self.assertFalse(response.data['is_staff'])
5757
self.assertTrue(
5858
self.client.login(username=username, password=password))
59-
# test with len(username) < 4
60-
submit['username'] = 'new'
61-
response = self.client.post(url, json.dumps(submit), content_type='application/json')
62-
self.assertEqual(response.status_code, 400)
6359
# test logout and login
6460
url = '/api/auth/logout/'
6561
response = self.client.post(url, content_type='application/json')

controller/api/views.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from rest_framework.response import Response
2323

2424
from api import models, serializers
25-
from .exceptions import UserRegistrationException
2625

2726
from django.conf import settings
2827

@@ -147,9 +146,6 @@ def pre_save(self, obj):
147146
obj.is_active = True
148147
obj.email = User.objects.normalize_email(obj.email)
149148
obj.set_password(obj.password)
150-
# FIXME: move this business logic to the model
151-
if len(obj.username) < 4:
152-
raise UserRegistrationException('username must be >= 4 characters in length')
153149
# Make this first signup an admin / superuser
154150
if not User.objects.filter(is_superuser=True).exists():
155151
obj.is_superuser = obj.is_staff = True

0 commit comments

Comments
 (0)