commit/galaxy-central: jgoecks: Standardize code and error messages on 'public name' rather than 'username'
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/0d1d62b8be2e/ changeset: 0d1d62b8be2e user: jgoecks date: 2012-01-11 15:44:39 summary: Standardize code and error messages on 'public name' rather than 'username' affected #: 3 files diff -r 67a8349ff9b9e3a37b8fadf96ac2e3ae64d3ea24 -r 0d1d62b8be2e574f0050a801eedfa59eba2b7563 lib/galaxy/security/validate_user_input.py --- a/lib/galaxy/security/validate_user_input.py +++ b/lib/galaxy/security/validate_user_input.py @@ -1,6 +1,6 @@ import re -VALID_USERNAME_RE = re.compile( "^[a-z0-9\-]+$" ) +VALID_PUBLICNAME_RE = re.compile( "^[a-z0-9\-]+$" ) def validate_email( trans, email, user=None, check_dup=True ): message = '' @@ -14,21 +14,21 @@ message = "User with that email already exists" return message -def validate_username( trans, username, user=None ): +def validate_publicname( trans, publicname, user=None ): # User names must be at least four characters in length and contain only lower-case # letters, numbers, and the '-' character. - if username in [ 'None', None, '' ]: + if publicname in [ 'None', None, '' ]: return '' - if user and user.username == username: + if user and user.username == publicname: return '' - if len( username ) < 4: - return "User name must be at least 4 characters in length" - if len( username ) > 255: - return "User name cannot be more than 255 characters in length" - if not( VALID_USERNAME_RE.match( username ) ): - return "User name must contain only lower-case letters, numbers and '-'" - if trans.sa_session.query( trans.app.model.User ).filter_by( username=username ).first(): - return "This user name is not available" + if len( publicname ) < 4: + return "Public name must be at least 4 characters in length" + if len( publicname ) > 255: + return "Public name cannot be more than 255 characters in length" + if not( VALID_PUBLICNAME_RE.match( publicname ) ): + return "Public name must contain only lower-case letters, numbers and '-'" + if trans.sa_session.query( trans.app.model.User ).filter_by( username=publicname ).first(): + return "Public name is taken; please choose another" return '' def validate_password( trans, password, confirm ): diff -r 67a8349ff9b9e3a37b8fadf96ac2e3ae64d3ea24 -r 0d1d62b8be2e574f0050a801eedfa59eba2b7563 lib/galaxy/web/base/controller.py --- a/lib/galaxy/web/base/controller.py +++ b/lib/galaxy/web/base/controller.py @@ -16,7 +16,7 @@ from galaxy.web.form_builder import WorkflowField, WorkflowMappingField, HistoryField, PasswordField, build_select_field from galaxy.visualization.tracks.data_providers import get_data_provider from galaxy.visualization.tracks.visual_analytics import get_tool_def -from galaxy.security.validate_user_input import validate_username +from galaxy.security.validate_user_input import validate_publicname from paste.httpexceptions import * from galaxy.exceptions import * @@ -1222,7 +1222,7 @@ def set_public_username( self, trans, id, username, **kwargs ): """ Set user's public username and delegate to sharing() """ user = trans.get_user() - message = validate_username( trans, username, user ) + message = validate_publicname( trans, username, user ) if message: return trans.fill_template( '/sharing_base.mako', item=self.get_item( trans, id ), message=message, status='error' ) user.username = username diff -r 67a8349ff9b9e3a37b8fadf96ac2e3ae64d3ea24 -r 0d1d62b8be2e574f0050a801eedfa59eba2b7563 lib/galaxy/web/controllers/user.py --- a/lib/galaxy/web/controllers/user.py +++ b/lib/galaxy/web/controllers/user.py @@ -10,7 +10,7 @@ from galaxy.web.form_builder import * from galaxy.util.json import from_json_string, to_json_string from galaxy.web.framework.helpers import iff -from galaxy.security.validate_user_input import validate_email, validate_username, validate_password +from galaxy.security.validate_user_input import validate_email, validate_publicname, validate_password log = logging.getLogger( __name__ ) @@ -698,7 +698,7 @@ if user and params.get( 'change_username_button', False ): username = kwd.get( 'username', '' ) if username: - message = validate_username( trans, username, user ) + message = validate_publicname( trans, username, user ) if message: status = 'error' else: @@ -736,7 +736,7 @@ # Validate the new values for email and username message = validate_email( trans, email, user ) if not message and username: - message = validate_username( trans, username, user ) + message = validate_publicname( trans, username, user ) if message: status = 'error' else: @@ -878,7 +878,7 @@ if not message: message = validate_password( trans, password, confirm ) if not message and username: - message = validate_username( trans, username ) + message = validate_publicname( trans, username ) if not message: if webapp == 'galaxy': if self.get_all_forms( trans, Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
Bitbucket