diff options
author | Rodney Ewing <ewing.rj@gmail.com> | 2013-05-17 07:51:08 -0700 |
---|---|---|
committer | Rodney Ewing <ewing.rj@gmail.com> | 2013-05-24 16:52:48 -0700 |
commit | f644293ea8768b82391394388067678c8e70ea0a (patch) | |
tree | 9f6d090e83f9a12a1013b56ece0dfb64f7dd8f76 /mediagoblin/auth/tools.py | |
parent | 7a98eb73d9f1b05cc34e4780707498f16f1d010b (diff) | |
download | mediagoblin-f644293ea8768b82391394388067678c8e70ea0a.tar.lz mediagoblin-f644293ea8768b82391394388067678c8e70ea0a.tar.xz mediagoblin-f644293ea8768b82391394388067678c8e70ea0a.zip |
changed from sys.exit() to raise AuthError for handling no_auth=false in config and no auth plugin present
Diffstat (limited to 'mediagoblin/auth/tools.py')
-rw-r--r-- | mediagoblin/auth/tools.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/mediagoblin/auth/tools.py b/mediagoblin/auth/tools.py index f06182b2..bd171261 100644 --- a/mediagoblin/auth/tools.py +++ b/mediagoblin/auth/tools.py @@ -15,7 +15,6 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import logging -import sys import wtforms from mediagoblin import mg_globals @@ -56,14 +55,21 @@ def normalize_user_or_email_field(allow_email=True, allow_user=True): return _normalize_field +class AuthError(Exception): + def __init__(self): + self.value = 'No Authentication Plugin is enabled and no_auth = false'\ + ' in config!' + + def __str__(self): + return repr(self.value) + + def check_auth_enabled(): no_auth = mg_globals.app_config['no_auth'] auth_plugin = True if hook_handle('authentication') is not None else False if no_auth == 'false' and not auth_plugin: - print 'No authentication plugin is enabled and no_auth = false in ' \ - 'config! \n..Exiting' - sys.exit() + raise AuthError if no_auth == 'true' and not auth_plugin: _log.warning('No authentication is enabled') |