mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-29 17:42:12 +08:00
move logic to webapps.py
This commit is contained in:
committed by
mvdbeek
parent
ae3afae8f0
commit
8553ea2c6e
@@ -24,7 +24,7 @@ from sqlalchemy.orm import joinedload
|
||||
from sqlalchemy.orm.exc import NoResultFound
|
||||
|
||||
from galaxy import util
|
||||
from galaxy.exceptions import MessageException
|
||||
from galaxy.exceptions import ConfigurationError, MessageException
|
||||
from galaxy.managers import context
|
||||
from galaxy.util import (
|
||||
asbool,
|
||||
@@ -630,16 +630,31 @@ class GalaxyWebTransaction(base.DefaultWebTransaction,
|
||||
self.set_cookie(self.security.encode_guid(self.galaxy_session.session_key),
|
||||
name=name, path=self.app.config.cookie_path)
|
||||
|
||||
def check_user_library_import_dir(self, user):
|
||||
if self.app.config.user_library_import_dir_auto_creation:
|
||||
# try to create a user library import directory
|
||||
try:
|
||||
self.app.config._ensure_directory(os.path.join(self.app.config.user_library_import_dir, user.email))
|
||||
except ConfigurationError as e:
|
||||
self.log_event(str(e))
|
||||
|
||||
def user_checks(self, user):
|
||||
"""
|
||||
This could contain more checks around a user upon login
|
||||
"""
|
||||
self.check_user_library_import_dir(user)
|
||||
|
||||
def handle_user_login(self, user):
|
||||
"""
|
||||
Login a new user (possibly newly created)
|
||||
|
||||
- do some 'system' checks (if any) for this user
|
||||
- create a new session
|
||||
- associate new session with user
|
||||
- if old session had a history and it was not associated with a user, associate it with the new session,
|
||||
otherwise associate the current session's history with the user
|
||||
- add the disk usage of the current session to the user's total disk usage
|
||||
"""
|
||||
self.user_checks(user)
|
||||
# Set the previous session
|
||||
prev_galaxy_session = self.galaxy_session
|
||||
prev_galaxy_session.is_valid = False
|
||||
|
||||
@@ -3,7 +3,6 @@ Contains the user interface in the Universe class
|
||||
"""
|
||||
|
||||
import logging
|
||||
import os
|
||||
import random
|
||||
import socket
|
||||
from datetime import datetime, timedelta
|
||||
@@ -22,7 +21,6 @@ from galaxy import (
|
||||
util,
|
||||
web
|
||||
)
|
||||
from galaxy.exceptions import ConfigurationError
|
||||
from galaxy.queue_worker import send_local_control_task
|
||||
from galaxy.security.validate_user_input import (
|
||||
transform_publicname,
|
||||
@@ -512,7 +510,7 @@ class User(BaseUIController, UsesFormDefinitionsMixin, CreatesUsersMixin, Create
|
||||
if success:
|
||||
# The handle_user_login() method has a call to the history_set_default_permissions() method
|
||||
# (needed when logging in with a history), user needs to have default permissions set before logging in
|
||||
self.handle_user_login(trans, user)
|
||||
trans.handle_user_login(user)
|
||||
trans.log_event("User (auto) created a new account")
|
||||
trans.log_event("User logged in")
|
||||
else:
|
||||
@@ -557,30 +555,12 @@ class User(BaseUIController, UsesFormDefinitionsMixin, CreatesUsersMixin, Create
|
||||
status = 'warning'
|
||||
return (message, status, user, success)
|
||||
|
||||
def check_user_library_import_dir(self, user):
|
||||
if self.app.config.user_library_import_dir_auto_creation:
|
||||
# try to create a user library import directory
|
||||
try:
|
||||
self.app.config._ensure_directory(os.path.join(self.app.config.user_library_import_dir, user.email))
|
||||
except ConfigurationError as e:
|
||||
self.log_event(str(e))
|
||||
|
||||
def user_checks(self, user):
|
||||
"""
|
||||
This could contain more checks around a user upon login
|
||||
"""
|
||||
self.check_user_library_import_dir(user)
|
||||
|
||||
def handle_user_login(self, trans, user):
|
||||
self.user_checks(user)
|
||||
trans.handle_user_login(user)
|
||||
|
||||
def proceed_login(self, trans, user, redirect):
|
||||
"""
|
||||
Function processes user login. It is called in case all the login requirements are valid.
|
||||
"""
|
||||
message = ''
|
||||
self.handle_user_login(trans, user)
|
||||
trans.handle_user_login(user)
|
||||
if trans.webapp.name == 'galaxy':
|
||||
trans.log_event("User logged in")
|
||||
message = 'You are now logged in as %s.<br>You can <a target="_top" href="%s">go back to the page you were visiting</a> or <a target="_top" href="%s">go to the home page</a>.' % \
|
||||
|
||||
Reference in New Issue
Block a user