1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/5e6da19ffd90/ Changeset: 5e6da19ffd90 User: dannon Date: 2015-01-13 21:27:35+00:00 Summary: Make password reset via link feature work for the toolshed too. Affected #: 5 files diff -r d2cafc77eee48d07b1958e395f6a8cf58770cf94 -r 5e6da19ffd907f39afd795e5d43b306071556bad lib/galaxy/webapps/galaxy/controllers/user.py --- a/lib/galaxy/webapps/galaxy/controllers/user.py +++ b/lib/galaxy/webapps/galaxy/controllers/user.py @@ -1155,7 +1155,7 @@ message = "You may only reset your own password." status = 'error' else: - prt = model.PasswordResetToken( reset_user ) + prt = trans.app.model.PasswordResetToken( reset_user ) trans.sa_session.add( prt ) trans.sa_session.flush() host = trans.request.host.split( ':' )[ 0 ] diff -r d2cafc77eee48d07b1958e395f6a8cf58770cf94 -r 5e6da19ffd907f39afd795e5d43b306071556bad lib/galaxy/webapps/tool_shed/model/__init__.py --- a/lib/galaxy/webapps/tool_shed/model/__init__.py +++ b/lib/galaxy/webapps/tool_shed/model/__init__.py @@ -1,7 +1,9 @@ import logging import operator import os +from datetime import datetime, timedelta from galaxy import util +from galaxy.util import unique_id from galaxy.util.bunch import Bunch from galaxy.util.hash_util import new_secure_hash from galaxy.model.item_attrs import Dictifiable @@ -61,6 +63,16 @@ self.password = new_secure_hash( text_type=cleartext ) +class PasswordResetToken( object ): + def __init__( self, user, token=None): + if token: + self.token = token + else: + self.token = unique_id() + self.user = user + self.expiration_time = datetime.now() + timedelta(hours=24) + + class Group( object, Dictifiable ): dict_collection_visible_keys = ( 'id', 'name' ) dict_element_visible_keys = ( 'id', 'name' ) @@ -85,7 +97,7 @@ self.description = description self.type = type self.deleted = deleted - + @property def is_repository_admin_role( self ): # A repository admin role must always be associated with a repository. The mapper returns an diff -r d2cafc77eee48d07b1958e395f6a8cf58770cf94 -r 5e6da19ffd907f39afd795e5d43b306071556bad lib/galaxy/webapps/tool_shed/model/mapping.py --- a/lib/galaxy/webapps/tool_shed/model/mapping.py +++ b/lib/galaxy/webapps/tool_shed/model/mapping.py @@ -37,6 +37,11 @@ Column( "deleted", Boolean, index=True, default=False ), Column( "purged", Boolean, index=True, default=False ) ) +PasswordResetToken.table = Table("password_reset_token", metadata, + Column( "token", String( 32 ), primary_key=True, unique=True, index=True ), + Column( "expiration_time", DateTime ), + Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True ) ) + Group.table = Table( "galaxy_group", metadata, Column( "id", Integer, primary_key=True ), Column( "create_time", DateTime, default=now ), @@ -204,6 +209,9 @@ galaxy_sessions=relation( GalaxySession, order_by=desc( GalaxySession.table.c.update_time ) ), api_keys=relation( APIKeys, backref="user", order_by=desc( APIKeys.table.c.create_time ) ) ) ) +mapper( PasswordResetToken, PasswordResetToken.table, + properties=dict( user=relation( User, backref="reset_tokens") ) ) + mapper( APIKeys, APIKeys.table, properties = {} ) diff -r d2cafc77eee48d07b1958e395f6a8cf58770cf94 -r 5e6da19ffd907f39afd795e5d43b306071556bad lib/galaxy/webapps/tool_shed/model/migrate/versions/0024_password_reset.py --- /dev/null +++ b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0024_password_reset.py @@ -0,0 +1,43 @@ +""" +Migration script for the password reset table +""" + +from sqlalchemy import * +from sqlalchemy.orm import * +from migrate import * +from migrate.changeset import * +from galaxy.model.custom_types import * + +import datetime +now = datetime.datetime.utcnow + +import logging +log = logging.getLogger( __name__ ) + +metadata = MetaData() + +PasswordResetToken_table = Table("password_reset_token", metadata, + Column( "token", String( 32 ), primary_key=True, unique=True, index=True ), + Column( "expiration_time", DateTime ), + Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True )) + + +def upgrade(migrate_engine): + metadata.bind = migrate_engine + print __doc__ + metadata.reflect() + try: + PasswordResetToken_table.create() + except Exception as e: + print str(e) + log.exception("Creating %s table failed: %s" % (PasswordResetToken_table.name, str( e ) ) ) + + +def downgrade(migrate_engine): + metadata.bind = migrate_engine + metadata.reflect() + try: + PasswordResetToken_table.drop() + except Exception as e: + print str(e) + log.exception("Dropping %s table failed: %s" % (PasswordResetToken_table.name, str( e ) ) ) diff -r d2cafc77eee48d07b1958e395f6a8cf58770cf94 -r 5e6da19ffd907f39afd795e5d43b306071556bad templates/user/index.mako --- a/templates/user/index.mako +++ b/templates/user/index.mako @@ -18,6 +18,7 @@ <li><a href="${h.url_for( controller='user', action='logout', logout_all=True )}" target="_top">${_('Logout')}</a> ${_('of all user sessions')}</li> %else: <li><a href="${h.url_for( controller='user', action='manage_user_info', cntrller=cntrller )}">${_('Manage your information')}</a></li> + <li><a href="${h.url_for( controller='user', action='change_password' )}">${_('Change your password')}</a></li><li><a href="${h.url_for( controller='user', action='api_keys', cntrller=cntrller )}">${_('Manage your API keys')}</a></li><li><a href="${h.url_for( controller='repository', action='manage_email_alerts', cntrller=cntrller )}">${_('Manage your email alerts')}</a></li><li><a href="${h.url_for( controller='user', action='logout', logout_all=True )}" target="_top">${_('Logout')}</a> ${_('of all user sessions')}</li> 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.