commit/galaxy-central: natefoo: Minor fix for setting the username during user creation under use_remote_user = True. Converts the user portion of the user's email to lowercase and replaces invalid characters with '-' as per the public name format requirements.
1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/4933de88cdb0/ changeset: r5483:4933de88cdb0 user: natefoo date: 2011-04-29 16:35:42 summary: Minor fix for setting the username during user creation under use_remote_user = True. Converts the user portion of the user's email to lowercase and replaces invalid characters with '-' as per the public name format requirements. affected #: 1 file (231 bytes) --- a/lib/galaxy/web/framework/__init__.py Thu Apr 28 22:07:58 2011 -0400 +++ b/lib/galaxy/web/framework/__init__.py Fri Apr 29 10:35:42 2011 -0400 @@ -437,14 +437,17 @@ if not user.default_permissions: self.app.security_agent.user_set_default_permissions( user, history=True, dataset=True ) elif user is None: - username = remote_user_email.split( '@', 1 )[0] + username = remote_user_email.split( '@', 1 )[0].lower() random.seed() user = self.app.model.User( email=remote_user_email ) user.set_password_cleartext( ''.join( random.sample( string.letters + string.digits, 12 ) ) ) user.external = True + # Replace invalid characters in the username + for char in filter( lambda x: x not in string.ascii_lowercase + string.digits + '-', username ): + username = username.replace( char, '-' ) # Find a unique username - user can change it later if ( self.sa_session.query( self.app.model.User ).filter_by( username=username ).first() ): - i = 0 + i = 1 while ( self.sa_session.query( self.app.model.User ).filter_by( username=(username + '-' + str(i) ) ).first() ): i += 1 username += '-' + str(i) 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