Skip to content

Commit

Permalink
Remove CreatesUsersMixin from base controller
Browse files Browse the repository at this point in the history
  • Loading branch information
guerler committed Nov 28, 2018
1 parent 3065d7c commit 98a1ded
Showing 1 changed file with 2 additions and 28 deletions.
30 changes: 2 additions & 28 deletions lib/galaxy/web/base/controller.py
Expand Up @@ -177,9 +177,9 @@ def get_object(self, trans, id, class_name, check_ownership=False, check_accessi
log.exception("Exception in get_object check for %s %s:", class_name, str(id))
raise Exception('Server error retrieving %s id ( %s ).' % (class_name, str(id)))

def message_exception(self, trans, message):
def message_exception(self, trans, message, sanitize=True):
trans.response.status = 400
return {'err_msg': util.sanitize_text(message)}
return {'err_msg': util.sanitize_text(message) if sanitize else message}


class BaseAPIController(BaseController):
Expand Down Expand Up @@ -339,32 +339,6 @@ def __init__(self, extension, dtype, type_extension, mimetype, display_in_upload
#


class CreatesUsersMixin(object):
"""
Mixin centralizing logic for user creation between web and API controller.
Web controller handles additional features such e-mail subscription, activation,
user forms, etc.... API created users are much more vanilla for the time being.
"""

def create_user(self, trans, email, username, password):
user = trans.app.model.User(email=email)
user.set_password_cleartext(password)
user.username = username
if trans.app.config.user_activation_on:
user.active = False
else:
user.active = True # Activation is off, every new user is active by default.
trans.sa_session.add(user)
trans.sa_session.flush()
trans.app.security_agent.create_private_user_role(user)
if trans.webapp.name == 'galaxy':
# We set default user permissions, before we log in and set the default history permissions
trans.app.security_agent.user_set_default_permissions(user,
default_access_private=trans.app.config.new_user_dataset_access_role_default_private)
return user


class CreatesApiKeysMixin(object):
"""
Mixing centralizing logic for creating API keys for user objects.
Expand Down

0 comments on commit 98a1ded

Please sign in to comment.