diff --git a/data/model/organization.py b/data/model/organization.py index 949e6766a..429d2566d 100644 --- a/data/model/organization.py +++ b/data/model/organization.py @@ -19,11 +19,8 @@ def create_organization(name, email, creating_user, email_required=True): team.add_user_to_team(creating_user, owners_team) return new_org - except InvalidUsernameException: - msg = ('Invalid organization name: %s Organization names must consist ' + - 'solely of lower case letters, numbers, and underscores. ' + - '[a-z0-9_]') % name - raise InvalidOrganizationException(msg) + except InvalidUsernameException as iue: + raise InvalidOrganizationException(iue.message) def get_organization(name): diff --git a/data/model/user.py b/data/model/user.py index ffe5f2ec7..ddb27400d 100644 --- a/data/model/user.py +++ b/data/model/user.py @@ -57,7 +57,7 @@ def create_user_noverify(username, email, email_required=True, prompts=tuple()): (username_valid, username_issue) = validate_username(username) if not username_valid: - raise InvalidUsernameException('Invalid username %s: %s' % (username, username_issue)) + raise InvalidUsernameException('Invalid namespace %s: %s' % (username, username_issue)) try: existing = User.get((User.username == username) | (User.email == email)) diff --git a/static/directives/signup-form.html b/static/directives/signup-form.html index 44b38bfab..6430d2e16 100644 --- a/static/directives/signup-form.html +++ b/static/directives/signup-form.html @@ -16,7 +16,7 @@ Usernames with dots or dashes are incompatible with Docker version 1.8 or older
- Usernames must be alphanumeric and be at least four characters in length + Usernames must be alphanumeric and between four and thirty characters in length
diff --git a/static/js/app.js b/static/js/app.js index 2b4292136..fd163f262 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -1,6 +1,6 @@ var TEAM_PATTERN = '^[a-z][a-z0-9]+$'; var ROBOT_PATTERN = '^[a-z][a-z0-9_]{3,29}$'; -var USERNAME_PATTERN = '^([a-z0-9]+(?:[._-][a-z0-9]+)*){4,30}$'; +var USERNAME_PATTERN = '^(?=.{4,30}$)([a-z0-9]+(?:[._-][a-z0-9]+)*)$'; // Define the pages module. quayPages = angular.module('quayPages', [], function(){}); diff --git a/static/partials/new-organization.html b/static/partials/new-organization.html index d77160201..359824673 100644 --- a/static/partials/new-organization.html +++ b/static/partials/new-organization.html @@ -48,10 +48,10 @@ Organization names with dots or dashes are incompatible with Docker version 1.8 or older - Organization names must be alphanumeric and be at least four characters in length + Organization names must be alphanumeric, be at least four characters in length and max thirty characters in length - This will also be the namespace for your repositories. Must be alphanumeric, all lowercase and at least four characters long. + This will also be the namespace for your repositories. Must be alphanumeric, all lowercase, at least four characters long and at most thirty characters long.
diff --git a/test/test_api_usage.py b/test/test_api_usage.py index f56aa3e20..095ab9b3e 100644 --- a/test/test_api_usage.py +++ b/test/test_api_usage.py @@ -651,7 +651,7 @@ class TestCreateNewUser(ApiTestCase): email='test@example.com'), expected_code=400) - self.assertEquals('Invalid username a: Username must be between 4 and 30 characters in length', + self.assertEquals('Invalid namespace a: Namespace must be between 4 and 30 characters in length', json['detail']) def test_trycreateregexmismatch(self): @@ -661,7 +661,7 @@ class TestCreateNewUser(ApiTestCase): email='test@example.com'), expected_code=400) - self.assertEquals('Invalid username auserName: Username must match expression ^([a-z0-9]+(?:[._-][a-z0-9]+)*)$', + self.assertEquals('Invalid namespace auserName: Namespace must match expression ^([a-z0-9]+(?:[._-][a-z0-9]+)*)$', json['detail']) def test_createuser(self): diff --git a/util/validation.py b/util/validation.py index fa878c185..9be53e43d 100644 --- a/util/validation.py +++ b/util/validation.py @@ -35,11 +35,11 @@ def validate_email(email_address): def validate_username(username): # Based off the restrictions defined in the Docker Registry API spec if not re.match(VALID_USERNAME_REGEX, username): - return (False, 'Username must match expression ' + VALID_USERNAME_REGEX) + return (False, 'Namespace must match expression ' + VALID_USERNAME_REGEX) length_match = (len(username) >= MIN_USERNAME_LENGTH and len(username) <= MAX_USERNAME_LENGTH) if not length_match: - return (False, 'Username must be between %s and %s characters in length' % + return (False, 'Namespace must be between %s and %s characters in length' % (MIN_USERNAME_LENGTH, MAX_USERNAME_LENGTH)) return (True, '')