1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/d53d0150e936/
Changeset: d53d0150e936
User: martenson
Date: 2014-11-04 15:27:24+00:00
Summary: Merged in martenson/galaxy-central-marten (pull request #548)
changesto user account updates
Affected #: 2 files
diff -r c7c9023e750ebae364c63345e59f2370f3f0905a -r d53d0150e936944c6a9e10dad1533a9645d37c48 lib/galaxy/webapps/galaxy/controllers/user.py
--- a/lib/galaxy/webapps/galaxy/controllers/user.py
+++ b/lib/galaxy/webapps/galaxy/controllers/user.py
@@ -573,7 +573,7 @@
email = trans.user.email
if username is None: # User is coming from outside registration form, load email from trans
username = trans.user.username
- is_activation_sent = self.send_verification_email( trans, email, username)
+ is_activation_sent = self.send_verification_email( trans, email, username )
if is_activation_sent:
message = 'This account has not been activated yet. The activation link has been sent again. Please check your email address <b>%s</b> including the spam/trash folder.<br><a target="_top" href="%s">Return to the home page</a>.' % ( email, url_for( '/' ) )
status = 'error'
@@ -819,7 +819,7 @@
def prepare_activation_link( self, trans, email ):
"""
- Prepares the account activation link for the user.
+ Prepare the account activation link for the user.
"""
activation_token = self.get_activation_token( trans, email )
activation_link = url_for( controller='user', action='activate', activation_token=activation_token, email=email, qualified=True )
@@ -827,7 +827,7 @@
def get_activation_token( self, trans, email ):
"""
- Checks for the activation token. Creates new activation token and stores it in the database if none found.
+ Check for the activation token. Create new activation token and store it in the database if no token found.
"""
user = trans.sa_session.query( trans.app.model.User ).filter( trans.app.model.User.table.c.email == email ).first()
activation_token = user.activation_token
@@ -841,7 +841,7 @@
@web.expose
def activate( self, trans, **kwd ):
"""
- Function checks whether token fits the user and then activates the user's account.
+ Check whether token fits the user and then activate the user's account.
"""
params = util.Params( kwd, sanitize=False )
email = urllib.unquote( params.get( 'email', None ) )
@@ -849,7 +849,7 @@
if email is None or activation_token is None:
# We don't have the email or activation_token, show error.
- return trans.show_error_message( "You are using wrong activation link. Try to log-in and we will send you a new activation email. <br><a href='%s'>Go to login page.</a>" ) % web.url_for( controller="root", action="index" )
+ return trans.show_error_message( "You are using an invalid activation link. Try to log in and we will send you a new activation email. <br><a href='%s'>Go to login page.</a>" ) % web.url_for( controller="root", action="index" )
else:
# Find the user
user = trans.sa_session.query( trans.app.model.User ).filter( trans.app.model.User.table.c.email == email ).first()
@@ -859,12 +859,12 @@
if user.activation_token == activation_token:
user.activation_token = None
user.active = True
- trans.sa_session.add(user)
+ trans.sa_session.add( user )
trans.sa_session.flush()
return trans.show_ok_message( "Your account has been successfully activated! <br><a href='%s'>Go to login page.</a>" ) % web.url_for( controller='root', action='index' )
else:
# Tokens don't match. Activation is denied.
- return trans.show_error_message( "You are using wrong activation link. Try to log in and we will send you a new activation email. <br><a href='%s'>Go to login page.</a>" ) % web.url_for( controller='root', action='index' )
+ return trans.show_error_message( "You are using an invalid activation link. Try to log in and we will send you a new activation email. <br><a href='%s'>Go to login page.</a>" ) % web.url_for( controller='root', action='index' )
return
def __get_user_type_form_definition( self, trans, user=None, **kwd ):
@@ -984,6 +984,9 @@
@web.expose
def edit_info( self, trans, cntrller, **kwd ):
+ """
+ Edit user information = username, email or password.
+ """
params = util.Params( kwd )
is_admin = cntrller == 'admin' and trans.user_is_admin()
message = util.restore_text( params.get( 'message', '' ) )
@@ -1001,6 +1004,7 @@
# Editing email and username
email = util.restore_text( params.get( 'email', '' ) )
username = util.restore_text( params.get( 'username', '' ) ).lower()
+
# Validate the new values for email and username
message = validate_email( trans, email, user )
if not message and username:
@@ -1008,15 +1012,32 @@
if message:
status = 'error'
else:
- # The user's private role name must match the user's login ( email )
- private_role = trans.app.security_agent.get_private_user_role( user )
- private_role.name = email
- private_role.description = 'Private role for ' + email
- # Now change the user info
- user.email = email
- user.username = username
- trans.sa_session.add_all( ( user, private_role ) )
- trans.sa_session.flush()
+ if ( user.email != email ):
+ # The user's private role name must match the user's login ( email )
+ private_role = trans.app.security_agent.get_private_user_role( user )
+ private_role.name = email
+ private_role.description = 'Private role for ' + email
+ # Change the email itself
+ user.email = email
+ trans.sa_session.add_all( ( user, private_role ) )
+ trans.sa_session.flush()
+ if trans.webapp.name == 'galaxy' and trans.app.config.user_activation_on:
+ user.active = False
+ trans.sa_session.add( user )
+ trans.sa_session.flush()
+ is_activation_sent = self.send_verification_email( trans, user.email, user.username )
+ if is_activation_sent:
+ message = 'The login information has been updated with the changes.<br>Verification email has been sent to your new email address. Please verify it by clicking the activation link in the email.<br>Please check your spam/trash folder in case you cannot find the message.'
+ success = True
+ else:
+ message = 'Unable to send activation email, please contact your local Galaxy administrator.'
+ if trans.app.config.error_email_to is not None:
+ message += ' Contact: %s' % trans.app.config.error_email_to
+ success = False
+ if ( user.username != username ):
+ user.username = username
+ trans.sa_session.add( user )
+ trans.sa_session.flush()
message = 'The login information has been updated with the changes.'
elif user and params.get( 'change_password_button', False ):
# Editing password. Do not sanitize passwords, so get from kwd
@@ -1093,6 +1114,9 @@
@web.expose
def reset_password( self, trans, email=None, **kwd ):
+ """
+ Reset the user's password. Send him/her an email with the new password.
+ """
if trans.app.config.smtp_server is None:
return trans.show_error_message( "Mail is not configured for this Galaxy instance. Please contact your local Galaxy administrator." )
message = util.sanitize_text(util.restore_text( kwd.get( 'message', '' ) ))
@@ -1162,7 +1186,7 @@
@web.expose
def set_default_permissions( self, trans, cntrller, **kwd ):
- """Sets the user's default permissions for the new histories"""
+ """Set the user's default permissions for the new histories"""
params = util.Params( kwd )
message = util.restore_text( params.get( 'message', '' ) )
status = params.get( 'status', 'done' )
diff -r c7c9023e750ebae364c63345e59f2370f3f0905a -r d53d0150e936944c6a9e10dad1533a9645d37c48 templates/user/info.mako
--- a/templates/user/info.mako
+++ b/templates/user/info.mako
@@ -3,6 +3,80 @@
<% is_admin = cntrller == 'admin' and trans.user_is_admin() %><%def name="render_user_info()">
+
+ <script type="text/javascript">
+ $(document).ready(function() {
+
+ function validateString(test_string, type) {
+ var mail_re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))(a)((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
+ var username_re = /^[a-z0-9\-]{4,255}$/;
+ if (type === 'email') {
+ return mail_re.test(test_string);
+ } else if (type === 'username'){
+ return username_re.test(test_string);
+ }
+ }
+
+ function renderError(message) {
+ $(".donemessage").hide();
+ if ($(".errormessage").length === 1) {
+ $(".errormessage").html(message);
+ } else {
+ var div = document.createElement( "div" );
+ div.className = "errormessage";
+ div.innerHTML = message;
+ document.body.insertBefore( div, document.body.firstChild );
+ }
+ }
+ function renderDone(message) {
+ $(".errormessage").hide();
+ if ($(".donemessage").length === 1) {
+ $(".donemessage").html(message);
+ } else {
+ var div = document.createElement( "div" );
+ div.className = "donemessage";
+ div.innerHTML = message;
+ document.body.insertBefore( div, document.body.firstChild );
+ }
+ }
+
+ original_email = $( '#email_input' ).val();
+ original_username = $( '#name_input' ).val();
+
+ $( '#login_info' ).bind( 'submit', function( e ) {
+ var error_text_email= 'Please enter your valid email address.';
+ var error_text_email_long= 'Email cannot be more than 255 characters in length.';
+ var error_text_username_characters = 'Public name must contain only lowercase letters, numbers and "-". It also has to be shorter than 255 characters but longer than 3.';
+ var email = $( '#email_input' ).val();
+ var name = $( '#name_input' ).val();
+ var validForm = true;
+ var nothing_changed = ( original_email === email && original_username === name );
+ // we need this value to detect submitting at backend
+ var hidden_input = '<input type="hidden" id="login_info_button" name="login_info_button" value="Submit"/>';
+ $( '#send' ).attr( 'disabled', 'disabled' );
+ $( "#email_input" ).before( hidden_input );
+
+ if ( original_email !== email ){
+ if ( email.length > 255 ){ renderError( error_text_email_long ); validForm = false; }
+ else if ( !validateString( email, "email" ) ){ renderError( error_text_email ); validForm = false; }
+ }
+ if ( original_username !== name ){
+ if ( name && !( validateString( name,"username" ) ) ){ renderError( error_text_username_characters ); validForm = false; }
+ }
+ if ( nothing_changed ){
+ renderDone( "Nothing has changed." );
+ }
+ if ( !validForm || nothing_changed ) {
+ e.preventDefault();
+ // reactivate the button if the form wasn't submitted
+ $( '#send' ).removeAttr( 'disabled' );
+ }
+ });
+ });
+
+ </script>
+
+
<h2>Manage User Information</h2>
%if not is_admin:
<ul class="manage-table-actions">
@@ -16,7 +90,10 @@
<div class="toolFormTitle">Login Information</div><div class="form-row"><label>Email address:</label>
- <input type="text" name="email" value="${email}" size="40"/>
+ <input type="text" id ="email_input" name="email" value="${email}" size="40"/>
+ <div class="toolParamHelp" style="clear: both;">
+ If you change your email address you will receive an activation link in the new mailbox and you have to activate your account by visiting it.
+ </div></div><div class="form-row"><label>Public name:</label>
@@ -37,7 +114,7 @@
</div>
%endif
%else:
- <input type="text" name="username" size="40" value="${username}"/>
+ <input type="text" id="name_input" name="username" size="40" value="${username}"/><div class="toolParamHelp" style="clear: both;">
Your public name is an optional identifier that will be used to generate addresses for information
you share publicly. Public names must be at least four characters in length and contain only lower-case
@@ -46,7 +123,7 @@
%endif
</div><div class="form-row">
- <input type="submit" name="login_info_button" value="Save"/>
+ <input type="submit" id="send" name="login_info_button" value="Save"/></div></form></div>
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.
3 new commits in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/43bf2d91ca84/
Changeset: 43bf2d91ca84
User: martenson
Date: 2014-11-03 20:16:36+00:00
Summary: changes to account updates: added javascript valdiation of username and email changes; user account will be deactivated if you change an email address and you have to activate it once again
Affected #: 2 files
diff -r db6130ed74cd2186e8646e20a8c94993c114ff1a -r 43bf2d91ca84df43bea0c0dc9c8b5b1e1f4098b6 lib/galaxy/webapps/galaxy/controllers/user.py
--- a/lib/galaxy/webapps/galaxy/controllers/user.py
+++ b/lib/galaxy/webapps/galaxy/controllers/user.py
@@ -573,7 +573,7 @@
email = trans.user.email
if username is None: # User is coming from outside registration form, load email from trans
username = trans.user.username
- is_activation_sent = self.send_verification_email( trans, email, username)
+ is_activation_sent = self.send_verification_email( trans, email, username )
if is_activation_sent:
message = 'This account has not been activated yet. The activation link has been sent again. Please check your email address <b>%s</b> including the spam/trash folder.<br><a target="_top" href="%s">Return to the home page</a>.' % ( email, url_for( '/' ) )
status = 'error'
@@ -819,7 +819,7 @@
def prepare_activation_link( self, trans, email ):
"""
- Prepares the account activation link for the user.
+ Prepare the account activation link for the user.
"""
activation_token = self.get_activation_token( trans, email )
activation_link = url_for( controller='user', action='activate', activation_token=activation_token, email=email, qualified=True )
@@ -827,7 +827,7 @@
def get_activation_token( self, trans, email ):
"""
- Checks for the activation token. Creates new activation token and stores it in the database if none found.
+ Check for the activation token. Create new activation token and store it in the database if no token found.
"""
user = trans.sa_session.query( trans.app.model.User ).filter( trans.app.model.User.table.c.email == email ).first()
activation_token = user.activation_token
@@ -841,7 +841,7 @@
@web.expose
def activate( self, trans, **kwd ):
"""
- Function checks whether token fits the user and then activates the user's account.
+ Check whether token fits the user and then activate the user's account.
"""
params = util.Params( kwd, sanitize=False )
email = urllib.unquote( params.get( 'email', None ) )
@@ -849,7 +849,7 @@
if email is None or activation_token is None:
# We don't have the email or activation_token, show error.
- return trans.show_error_message( "You are using wrong activation link. Try to log-in and we will send you a new activation email. <br><a href='%s'>Go to login page.</a>" ) % web.url_for( controller="root", action="index" )
+ return trans.show_error_message( "You are using an invalid activation link. Try to log in and we will send you a new activation email. <br><a href='%s'>Go to login page.</a>" ) % web.url_for( controller="root", action="index" )
else:
# Find the user
user = trans.sa_session.query( trans.app.model.User ).filter( trans.app.model.User.table.c.email == email ).first()
@@ -859,12 +859,12 @@
if user.activation_token == activation_token:
user.activation_token = None
user.active = True
- trans.sa_session.add(user)
+ trans.sa_session.add( user )
trans.sa_session.flush()
return trans.show_ok_message( "Your account has been successfully activated! <br><a href='%s'>Go to login page.</a>" ) % web.url_for( controller='root', action='index' )
else:
# Tokens don't match. Activation is denied.
- return trans.show_error_message( "You are using wrong activation link. Try to log in and we will send you a new activation email. <br><a href='%s'>Go to login page.</a>" ) % web.url_for( controller='root', action='index' )
+ return trans.show_error_message( "You are using invalid activation link. Try to log in and we will send you a new activation email. <br><a href='%s'>Go to login page.</a>" ) % web.url_for( controller='root', action='index' )
return
def __get_user_type_form_definition( self, trans, user=None, **kwd ):
@@ -984,6 +984,9 @@
@web.expose
def edit_info( self, trans, cntrller, **kwd ):
+ """
+ Edit user information = username, email or password.
+ """
params = util.Params( kwd )
is_admin = cntrller == 'admin' and trans.user_is_admin()
message = util.restore_text( params.get( 'message', '' ) )
@@ -1001,6 +1004,7 @@
# Editing email and username
email = util.restore_text( params.get( 'email', '' ) )
username = util.restore_text( params.get( 'username', '' ) ).lower()
+
# Validate the new values for email and username
message = validate_email( trans, email, user )
if not message and username:
@@ -1008,15 +1012,32 @@
if message:
status = 'error'
else:
- # The user's private role name must match the user's login ( email )
- private_role = trans.app.security_agent.get_private_user_role( user )
- private_role.name = email
- private_role.description = 'Private role for ' + email
- # Now change the user info
- user.email = email
- user.username = username
- trans.sa_session.add_all( ( user, private_role ) )
- trans.sa_session.flush()
+ if ( user.email != email ):
+ # The user's private role name must match the user's login ( email )
+ private_role = trans.app.security_agent.get_private_user_role( user )
+ private_role.name = email
+ private_role.description = 'Private role for ' + email
+ # Change the email itself
+ user.email = email
+ trans.sa_session.add_all( ( user, private_role ) )
+ trans.sa_session.flush()
+ if trans.webapp.name == 'galaxy' and trans.app.config.user_activation_on:
+ user.active = False
+ trans.sa_session.add( user )
+ trans.sa_session.flush()
+ is_activation_sent = self.send_verification_email( trans, user.email, user.username )
+ if is_activation_sent:
+ message = 'The login information has been updated with the changes.<br>Verification email has been sent to your new email address. Please verify it by clicking the activation link in the email.<br>Please check your spam/trash folder in case you cannot find the message.'
+ success = True
+ else:
+ message = 'Unable to send activation email, please contact your local Galaxy administrator.'
+ if trans.app.config.error_email_to is not None:
+ message += ' Contact: %s' % trans.app.config.error_email_to
+ success = False
+ if ( user.username != username ):
+ user.username = username
+ trans.sa_session.add( user )
+ trans.sa_session.flush()
message = 'The login information has been updated with the changes.'
elif user and params.get( 'change_password_button', False ):
# Editing password. Do not sanitize passwords, so get from kwd
@@ -1093,6 +1114,9 @@
@web.expose
def reset_password( self, trans, email=None, **kwd ):
+ """
+ Reset the user's password. Send him/her an email with the new password.
+ """
if trans.app.config.smtp_server is None:
return trans.show_error_message( "Mail is not configured for this Galaxy instance. Please contact your local Galaxy administrator." )
message = util.sanitize_text(util.restore_text( kwd.get( 'message', '' ) ))
@@ -1162,7 +1186,7 @@
@web.expose
def set_default_permissions( self, trans, cntrller, **kwd ):
- """Sets the user's default permissions for the new histories"""
+ """Set the user's default permissions for the new histories"""
params = util.Params( kwd )
message = util.restore_text( params.get( 'message', '' ) )
status = params.get( 'status', 'done' )
diff -r db6130ed74cd2186e8646e20a8c94993c114ff1a -r 43bf2d91ca84df43bea0c0dc9c8b5b1e1f4098b6 templates/user/info.mako
--- a/templates/user/info.mako
+++ b/templates/user/info.mako
@@ -3,6 +3,80 @@
<% is_admin = cntrller == 'admin' and trans.user_is_admin() %><%def name="render_user_info()">
+
+ <script type="text/javascript">
+ $(document).ready(function() {
+
+ function validateString(test_string, type) {
+ var mail_re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))(a)((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
+ var username_re = /^[a-z0-9\-]{4,255}$/;
+ if (type === 'email') {
+ return mail_re.test(test_string);
+ } else if (type === 'username'){
+ return username_re.test(test_string);
+ }
+ }
+
+ function renderError(message) {
+ $(".donemessage").hide();
+ if ($(".errormessage").length === 1) {
+ $(".errormessage").html(message);
+ } else {
+ var div = document.createElement( "div" );
+ div.className = "errormessage";
+ div.innerHTML = message;
+ document.body.insertBefore( div, document.body.firstChild );
+ }
+ }
+ function renderDone(message) {
+ $(".errormessage").hide();
+ if ($(".donemessage").length === 1) {
+ $(".donemessage").html(message);
+ } else {
+ var div = document.createElement( "div" );
+ div.className = "donemessage";
+ div.innerHTML = message;
+ document.body.insertBefore( div, document.body.firstChild );
+ }
+ }
+
+ original_email = $( '#email_input' ).val();
+ original_username = $( '#name_input' ).val();
+
+ $( '#login_info' ).bind( 'submit', function( e ) {
+ var error_text_email= 'Please enter your valid email address.';
+ var error_text_email_long= 'Email cannot be more than 255 characters in length.';
+ var error_text_username_characters = 'Public name must contain only lowercase letters, numbers and "-". It also has to be shorter than 255 characters but longer than 3.';
+ var email = $( '#email_input' ).val();
+ var name = $( '#name_input' ).val();
+ var validForm = true;
+ var nothing_changed = ( original_email === email && original_username === name );
+ // we need this value to detect submitting at backend
+ var hidden_input = '<input type="hidden" id="login_info_button" name="login_info_button" value="Submit"/>';
+ $( '#send' ).attr( 'disabled', 'disabled' );
+ $( "#email_input" ).before( hidden_input );
+
+ if ( original_email !== email ){
+ if ( email.length > 255 ){ renderError( error_text_email_long ); validForm = false; }
+ else if ( !validateString( email, "email" ) ){ renderError( error_text_email ); validForm = false; }
+ }
+ if ( original_username !== name ){
+ if ( name && !( validateString( name,"username" ) ) ){ renderError( error_text_username_characters ); validForm = false; }
+ }
+ if ( nothing_changed ){
+ renderDone( "Nothing has changed." );
+ }
+ if ( !validForm || nothing_changed ) {
+ e.preventDefault();
+ // reactivate the button if the form wasn't submitted
+ $( '#send' ).removeAttr( 'disabled' );
+ }
+ });
+ });
+
+ </script>
+
+
<h2>Manage User Information</h2>
%if not is_admin:
<ul class="manage-table-actions">
@@ -16,7 +90,10 @@
<div class="toolFormTitle">Login Information</div><div class="form-row"><label>Email address:</label>
- <input type="text" name="email" value="${email}" size="40"/>
+ <input type="text" id ="email_input" name="email" value="${email}" size="40"/>
+ <div class="toolParamHelp" style="clear: both;">
+ If you change your email address you will receive an activation link in the new mailbox and you have to activate your account by visiting it.
+ </div></div><div class="form-row"><label>Public name:</label>
@@ -37,7 +114,7 @@
</div>
%endif
%else:
- <input type="text" name="username" size="40" value="${username}"/>
+ <input type="text" id="name_input" name="username" size="40" value="${username}"/><div class="toolParamHelp" style="clear: both;">
Your public name is an optional identifier that will be used to generate addresses for information
you share publicly. Public names must be at least four characters in length and contain only lower-case
@@ -46,7 +123,7 @@
%endif
</div><div class="form-row">
- <input type="submit" name="login_info_button" value="Save"/>
+ <input type="submit" id="send" name="login_info_button" value="Save"/></div></form></div>
https://bitbucket.org/galaxy/galaxy-central/commits/ef99f015a0d2/
Changeset: ef99f015a0d2
User: martenson
Date: 2014-11-04 15:26:53+00:00
Summary: gremmar
Affected #: 1 file
diff -r 43bf2d91ca84df43bea0c0dc9c8b5b1e1f4098b6 -r ef99f015a0d2100e3c3e139ddf3dbf7d5ca6a299 lib/galaxy/webapps/galaxy/controllers/user.py
--- a/lib/galaxy/webapps/galaxy/controllers/user.py
+++ b/lib/galaxy/webapps/galaxy/controllers/user.py
@@ -864,7 +864,7 @@
return trans.show_ok_message( "Your account has been successfully activated! <br><a href='%s'>Go to login page.</a>" ) % web.url_for( controller='root', action='index' )
else:
# Tokens don't match. Activation is denied.
- return trans.show_error_message( "You are using invalid activation link. Try to log in and we will send you a new activation email. <br><a href='%s'>Go to login page.</a>" ) % web.url_for( controller='root', action='index' )
+ return trans.show_error_message( "You are using an invalid activation link. Try to log in and we will send you a new activation email. <br><a href='%s'>Go to login page.</a>" ) % web.url_for( controller='root', action='index' )
return
def __get_user_type_form_definition( self, trans, user=None, **kwd ):
https://bitbucket.org/galaxy/galaxy-central/commits/d53d0150e936/
Changeset: d53d0150e936
User: martenson
Date: 2014-11-04 15:27:24+00:00
Summary: Merged in martenson/galaxy-central-marten (pull request #548)
changesto user account updates
Affected #: 2 files
diff -r c7c9023e750ebae364c63345e59f2370f3f0905a -r d53d0150e936944c6a9e10dad1533a9645d37c48 lib/galaxy/webapps/galaxy/controllers/user.py
--- a/lib/galaxy/webapps/galaxy/controllers/user.py
+++ b/lib/galaxy/webapps/galaxy/controllers/user.py
@@ -573,7 +573,7 @@
email = trans.user.email
if username is None: # User is coming from outside registration form, load email from trans
username = trans.user.username
- is_activation_sent = self.send_verification_email( trans, email, username)
+ is_activation_sent = self.send_verification_email( trans, email, username )
if is_activation_sent:
message = 'This account has not been activated yet. The activation link has been sent again. Please check your email address <b>%s</b> including the spam/trash folder.<br><a target="_top" href="%s">Return to the home page</a>.' % ( email, url_for( '/' ) )
status = 'error'
@@ -819,7 +819,7 @@
def prepare_activation_link( self, trans, email ):
"""
- Prepares the account activation link for the user.
+ Prepare the account activation link for the user.
"""
activation_token = self.get_activation_token( trans, email )
activation_link = url_for( controller='user', action='activate', activation_token=activation_token, email=email, qualified=True )
@@ -827,7 +827,7 @@
def get_activation_token( self, trans, email ):
"""
- Checks for the activation token. Creates new activation token and stores it in the database if none found.
+ Check for the activation token. Create new activation token and store it in the database if no token found.
"""
user = trans.sa_session.query( trans.app.model.User ).filter( trans.app.model.User.table.c.email == email ).first()
activation_token = user.activation_token
@@ -841,7 +841,7 @@
@web.expose
def activate( self, trans, **kwd ):
"""
- Function checks whether token fits the user and then activates the user's account.
+ Check whether token fits the user and then activate the user's account.
"""
params = util.Params( kwd, sanitize=False )
email = urllib.unquote( params.get( 'email', None ) )
@@ -849,7 +849,7 @@
if email is None or activation_token is None:
# We don't have the email or activation_token, show error.
- return trans.show_error_message( "You are using wrong activation link. Try to log-in and we will send you a new activation email. <br><a href='%s'>Go to login page.</a>" ) % web.url_for( controller="root", action="index" )
+ return trans.show_error_message( "You are using an invalid activation link. Try to log in and we will send you a new activation email. <br><a href='%s'>Go to login page.</a>" ) % web.url_for( controller="root", action="index" )
else:
# Find the user
user = trans.sa_session.query( trans.app.model.User ).filter( trans.app.model.User.table.c.email == email ).first()
@@ -859,12 +859,12 @@
if user.activation_token == activation_token:
user.activation_token = None
user.active = True
- trans.sa_session.add(user)
+ trans.sa_session.add( user )
trans.sa_session.flush()
return trans.show_ok_message( "Your account has been successfully activated! <br><a href='%s'>Go to login page.</a>" ) % web.url_for( controller='root', action='index' )
else:
# Tokens don't match. Activation is denied.
- return trans.show_error_message( "You are using wrong activation link. Try to log in and we will send you a new activation email. <br><a href='%s'>Go to login page.</a>" ) % web.url_for( controller='root', action='index' )
+ return trans.show_error_message( "You are using an invalid activation link. Try to log in and we will send you a new activation email. <br><a href='%s'>Go to login page.</a>" ) % web.url_for( controller='root', action='index' )
return
def __get_user_type_form_definition( self, trans, user=None, **kwd ):
@@ -984,6 +984,9 @@
@web.expose
def edit_info( self, trans, cntrller, **kwd ):
+ """
+ Edit user information = username, email or password.
+ """
params = util.Params( kwd )
is_admin = cntrller == 'admin' and trans.user_is_admin()
message = util.restore_text( params.get( 'message', '' ) )
@@ -1001,6 +1004,7 @@
# Editing email and username
email = util.restore_text( params.get( 'email', '' ) )
username = util.restore_text( params.get( 'username', '' ) ).lower()
+
# Validate the new values for email and username
message = validate_email( trans, email, user )
if not message and username:
@@ -1008,15 +1012,32 @@
if message:
status = 'error'
else:
- # The user's private role name must match the user's login ( email )
- private_role = trans.app.security_agent.get_private_user_role( user )
- private_role.name = email
- private_role.description = 'Private role for ' + email
- # Now change the user info
- user.email = email
- user.username = username
- trans.sa_session.add_all( ( user, private_role ) )
- trans.sa_session.flush()
+ if ( user.email != email ):
+ # The user's private role name must match the user's login ( email )
+ private_role = trans.app.security_agent.get_private_user_role( user )
+ private_role.name = email
+ private_role.description = 'Private role for ' + email
+ # Change the email itself
+ user.email = email
+ trans.sa_session.add_all( ( user, private_role ) )
+ trans.sa_session.flush()
+ if trans.webapp.name == 'galaxy' and trans.app.config.user_activation_on:
+ user.active = False
+ trans.sa_session.add( user )
+ trans.sa_session.flush()
+ is_activation_sent = self.send_verification_email( trans, user.email, user.username )
+ if is_activation_sent:
+ message = 'The login information has been updated with the changes.<br>Verification email has been sent to your new email address. Please verify it by clicking the activation link in the email.<br>Please check your spam/trash folder in case you cannot find the message.'
+ success = True
+ else:
+ message = 'Unable to send activation email, please contact your local Galaxy administrator.'
+ if trans.app.config.error_email_to is not None:
+ message += ' Contact: %s' % trans.app.config.error_email_to
+ success = False
+ if ( user.username != username ):
+ user.username = username
+ trans.sa_session.add( user )
+ trans.sa_session.flush()
message = 'The login information has been updated with the changes.'
elif user and params.get( 'change_password_button', False ):
# Editing password. Do not sanitize passwords, so get from kwd
@@ -1093,6 +1114,9 @@
@web.expose
def reset_password( self, trans, email=None, **kwd ):
+ """
+ Reset the user's password. Send him/her an email with the new password.
+ """
if trans.app.config.smtp_server is None:
return trans.show_error_message( "Mail is not configured for this Galaxy instance. Please contact your local Galaxy administrator." )
message = util.sanitize_text(util.restore_text( kwd.get( 'message', '' ) ))
@@ -1162,7 +1186,7 @@
@web.expose
def set_default_permissions( self, trans, cntrller, **kwd ):
- """Sets the user's default permissions for the new histories"""
+ """Set the user's default permissions for the new histories"""
params = util.Params( kwd )
message = util.restore_text( params.get( 'message', '' ) )
status = params.get( 'status', 'done' )
diff -r c7c9023e750ebae364c63345e59f2370f3f0905a -r d53d0150e936944c6a9e10dad1533a9645d37c48 templates/user/info.mako
--- a/templates/user/info.mako
+++ b/templates/user/info.mako
@@ -3,6 +3,80 @@
<% is_admin = cntrller == 'admin' and trans.user_is_admin() %><%def name="render_user_info()">
+
+ <script type="text/javascript">
+ $(document).ready(function() {
+
+ function validateString(test_string, type) {
+ var mail_re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))(a)((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
+ var username_re = /^[a-z0-9\-]{4,255}$/;
+ if (type === 'email') {
+ return mail_re.test(test_string);
+ } else if (type === 'username'){
+ return username_re.test(test_string);
+ }
+ }
+
+ function renderError(message) {
+ $(".donemessage").hide();
+ if ($(".errormessage").length === 1) {
+ $(".errormessage").html(message);
+ } else {
+ var div = document.createElement( "div" );
+ div.className = "errormessage";
+ div.innerHTML = message;
+ document.body.insertBefore( div, document.body.firstChild );
+ }
+ }
+ function renderDone(message) {
+ $(".errormessage").hide();
+ if ($(".donemessage").length === 1) {
+ $(".donemessage").html(message);
+ } else {
+ var div = document.createElement( "div" );
+ div.className = "donemessage";
+ div.innerHTML = message;
+ document.body.insertBefore( div, document.body.firstChild );
+ }
+ }
+
+ original_email = $( '#email_input' ).val();
+ original_username = $( '#name_input' ).val();
+
+ $( '#login_info' ).bind( 'submit', function( e ) {
+ var error_text_email= 'Please enter your valid email address.';
+ var error_text_email_long= 'Email cannot be more than 255 characters in length.';
+ var error_text_username_characters = 'Public name must contain only lowercase letters, numbers and "-". It also has to be shorter than 255 characters but longer than 3.';
+ var email = $( '#email_input' ).val();
+ var name = $( '#name_input' ).val();
+ var validForm = true;
+ var nothing_changed = ( original_email === email && original_username === name );
+ // we need this value to detect submitting at backend
+ var hidden_input = '<input type="hidden" id="login_info_button" name="login_info_button" value="Submit"/>';
+ $( '#send' ).attr( 'disabled', 'disabled' );
+ $( "#email_input" ).before( hidden_input );
+
+ if ( original_email !== email ){
+ if ( email.length > 255 ){ renderError( error_text_email_long ); validForm = false; }
+ else if ( !validateString( email, "email" ) ){ renderError( error_text_email ); validForm = false; }
+ }
+ if ( original_username !== name ){
+ if ( name && !( validateString( name,"username" ) ) ){ renderError( error_text_username_characters ); validForm = false; }
+ }
+ if ( nothing_changed ){
+ renderDone( "Nothing has changed." );
+ }
+ if ( !validForm || nothing_changed ) {
+ e.preventDefault();
+ // reactivate the button if the form wasn't submitted
+ $( '#send' ).removeAttr( 'disabled' );
+ }
+ });
+ });
+
+ </script>
+
+
<h2>Manage User Information</h2>
%if not is_admin:
<ul class="manage-table-actions">
@@ -16,7 +90,10 @@
<div class="toolFormTitle">Login Information</div><div class="form-row"><label>Email address:</label>
- <input type="text" name="email" value="${email}" size="40"/>
+ <input type="text" id ="email_input" name="email" value="${email}" size="40"/>
+ <div class="toolParamHelp" style="clear: both;">
+ If you change your email address you will receive an activation link in the new mailbox and you have to activate your account by visiting it.
+ </div></div><div class="form-row"><label>Public name:</label>
@@ -37,7 +114,7 @@
</div>
%endif
%else:
- <input type="text" name="username" size="40" value="${username}"/>
+ <input type="text" id="name_input" name="username" size="40" value="${username}"/><div class="toolParamHelp" style="clear: both;">
Your public name is an optional identifier that will be used to generate addresses for information
you share publicly. Public names must be at least four characters in length and contain only lower-case
@@ -46,7 +123,7 @@
%endif
</div><div class="form-row">
- <input type="submit" name="login_info_button" value="Save"/>
+ <input type="submit" id="send" name="login_info_button" value="Save"/></div></form></div>
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.
2 new commits in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/1370ef01209d/
Changeset: 1370ef01209d
User: dannon
Date: 2014-11-03 19:52:21+00:00
Summary: Patch from Eric Rasche, redacting a few things from sentry reports.
Affected #: 1 file
diff -r 1bb61cbf80825b0793a61d83f01925b57467d3a9 -r 1370ef01209d6b6329c9285891e94ebd2f7ccdb6 lib/galaxy/web/framework/middleware/sentry.py
--- a/lib/galaxy/web/framework/middleware/sentry.py
+++ b/lib/galaxy/web/framework/middleware/sentry.py
@@ -44,6 +44,25 @@
self.handle_exception(environ)
def handle_exception(self, environ):
+ headers = dict(get_headers(environ))
+ # Authorization header for REMOTE_USER sites consists of a base64() of
+ # their plaintext password. It is a security issue for this password to
+ # be exposed to a third party system which may or may not be under
+ # control of the same administrators as the local Authentication
+ # system. E.g. university LDAP systems.
+ if 'Authorization' in headers:
+ # Redact so the administrator knows that a value is indeed present.
+ headers['Authorization'] = 'redacted'
+ # Passing cookies allows for impersonation of users (depending on
+ # remote service) and can be considered a security risk as well. For
+ # multiple services running alongside Galaxy on the same host, this
+ # could allow a sentry user with access to logs to impersonate a user
+ # on another service. In the case of services like IPython, this can be
+ # a serious concern as that would allow for terminal access. Furthermore,
+ # very little debugging information can be gained as a result of having
+ # access to all of the users cookies (including Galaxy cookies)
+ if 'Cookie' in headers:
+ headers['Cookie'] = 'redacted'
event_id = self.client.captureException(
data={
'sentry.interfaces.Http': {
@@ -52,7 +71,7 @@
'query_string': environ.get('QUERY_STRING'),
# TODO
# 'data': environ.get('wsgi.input'),
- 'headers': dict(get_headers(environ)),
+ 'headers': headers,
'env': dict(get_environ(environ)),
}
},
https://bitbucket.org/galaxy/galaxy-central/commits/db6130ed74cd/
Changeset: db6130ed74cd
User: dannon
Date: 2014-11-03 20:04:17+00:00
Summary: Merge.
Affected #: 2 files
diff -r 1370ef01209d6b6329c9285891e94ebd2f7ccdb6 -r db6130ed74cd2186e8646e20a8c94993c114ff1a lib/galaxy/tools/evaluation.py
--- a/lib/galaxy/tools/evaluation.py
+++ b/lib/galaxy/tools/evaluation.py
@@ -362,6 +362,11 @@
try:
# Substituting parameters into the command
command_line = fill_template( command, context=param_dict )
+ cleaned_command_line = []
+ # Remove leading and trailing whitespace from each line for readability.
+ for line in command_line.split( '\n' ):
+ cleaned_command_line.append( line.strip() )
+ command_line = '\n'.join( cleaned_command_line )
# Remove newlines from command line, and any leading/trailing white space
command_line = command_line.replace( "\n", " " ).replace( "\r", " " ).strip()
except Exception:
diff -r 1370ef01209d6b6329c9285891e94ebd2f7ccdb6 -r db6130ed74cd2186e8646e20a8c94993c114ff1a test/install_and_test_tool_shed_repositories/repositories_with_tools/functional_tests.py
--- a/test/install_and_test_tool_shed_repositories/repositories_with_tools/functional_tests.py
+++ b/test/install_and_test_tool_shed_repositories/repositories_with_tools/functional_tests.py
@@ -441,7 +441,9 @@
pass
print "Database connection: ", database_connection
print "Install database connection: ", install_database_connection
- # Generate the shed_tool_data_table_conf.xml file.
+ # Generate the tool data table configuration files.
+ if not os.path.exists( galaxy_tool_data_table_conf_file ):
+ file( galaxy_tool_data_table_conf_file, 'w' ).write( install_and_test_base_util.tool_data_table_conf_xml_template )
file( shed_tool_data_table_conf_file, 'w' ).write( install_and_test_base_util.tool_data_table_conf_xml_template )
os.environ[ 'GALAXY_INSTALL_TEST_SHED_TOOL_DATA_TABLE_CONF' ] = shed_tool_data_table_conf_file
# ---- Start up a Galaxy instance ------------------------------------------------------
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.
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/1bb61cbf8082/
Changeset: 1bb61cbf8082
User: natefoo
Date: 2014-11-03 18:58:14+00:00
Summary: Handle all submission failures in the drmaa runner.
Affected #: 1 file
diff -r 25ea95428c508c7982a3f9ff2af855eac7c62dbb -r 1bb61cbf80825b0793a61d83f01925b57467d3a9 lib/galaxy/jobs/runners/drmaa.py
--- a/lib/galaxy/jobs/runners/drmaa.py
+++ b/lib/galaxy/jobs/runners/drmaa.py
@@ -13,6 +13,7 @@
from galaxy import eggs
from galaxy import model
from galaxy.jobs import JobDestination
+from galaxy.jobs.handler import DEFAULT_JOB_PUT_FAILURE_MESSAGE
from galaxy.jobs.runners import AsynchronousJobState, AsynchronousJobRunner
eggs.require( "drmaa" )
@@ -170,6 +171,7 @@
# TODO: configurable max tries and sleep
trynum = 0
external_job_id = None
+ fail_msg = None
while external_job_id is None and trynum < 5:
try:
external_job_id = self.ds.runJob(jt)
@@ -177,10 +179,16 @@
except ( drmaa.InternalException, drmaa.DeniedByDrmException ), e:
trynum += 1
log.warning( '(%s) drmaa.Session.runJob() failed, will retry: %s', galaxy_id_tag, e )
+ fail_msg = "Unable to run this job due to a cluster error, please retry it later"
time.sleep( 5 )
+ except:
+ log.exception( '(%s) drmaa.Session.runJob() failed unconditionally', galaxy_id_tag )
+ trynum = 5
else:
log.error( "(%s) All attempts to submit job failed" % galaxy_id_tag )
- job_wrapper.fail( "Unable to run this job due to a cluster error, please retry it later" )
+ if not fail_msg:
+ fail_msg = DEFAULT_JOB_PUT_FAILURE_MESSAGE
+ job_wrapper.fail( fail_msg )
self.ds.deleteJobTemplate( jt )
return
else:
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.
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/25ea95428c50/
Changeset: 25ea95428c50
User: nsoranzo
Date: 2014-10-31 16:16:20+00:00
Summary: API: Return also metrics for jobs when full=True and user is admin.
Affected #: 1 file
diff -r bd2ec092d2f57aa8526b7d6612403b7ae4354907 -r 25ea95428c508c7982a3f9ff2af855eac7c62dbb lib/galaxy/webapps/galaxy/api/jobs.py
--- a/lib/galaxy/webapps/galaxy/api/jobs.py
+++ b/lib/galaxy/webapps/galaxy/api/jobs.py
@@ -89,6 +89,9 @@
:type id: string
:param id: Specific job id
+ :type full: boolean
+ :param full: whether to return extra information
+
:rtype: dictionary
:returns: dictionary containing full description of job data
"""
@@ -97,6 +100,12 @@
full_output = util.asbool( kwd.get( 'full', 'false' ) )
if full_output:
job_dict.update( dict( stderr=job.stderr, stdout=job.stdout ) )
+ if trans.user_is_admin():
+
+ def metric_to_dict(metric):
+ return dict(zip(['title', 'value'], trans.app.job_metrics.format(metric.plugin, metric.metric_name, metric.metric_value)))
+
+ job_dict['job_metrics'] = [metric_to_dict(metric) for metric in job.metrics]
return job_dict
@expose_api
@@ -248,11 +257,11 @@
) )
for k, v in input_data.items():
- """
- Here we are attempting to link the inputs to the underlying dataset (not the dataset association)
- This way, if the calulation was done using a copied HDA (copied from the library or another history)
- the search will still find the job
- """
+ # Here we are attempting to link the inputs to the underlying
+ # dataset (not the dataset association).
+ # This way, if the calculation was done using a copied HDA
+ # (copied from the library or another history), the search will
+ # still find the job
a = aliased( trans.app.model.JobToInputDatasetAssociation )
b = aliased( trans.app.model.HistoryDatasetAssociation )
query = query.filter( and_(
@@ -264,9 +273,7 @@
out = []
for job in query.all():
- """
- check to make sure none of the output files have been deleted
- """
+ # check to make sure none of the output files have been deleted
if all( list( a.dataset.deleted == False for a in job.output_datasets ) ):
out.append( self.encode_all_ids( trans, job.to_dict( 'element' ), True ) )
return out
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.