From f644293ea8768b82391394388067678c8e70ea0a Mon Sep 17 00:00:00 2001 From: Rodney Ewing Date: Fri, 17 May 2013 07:51:08 -0700 Subject: [PATCH] changed from sys.exit() to raise AuthError for handling no_auth=false in config and no auth plugin present --- mediagoblin/auth/tools.py | 14 ++++++++++---- 1 file 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 . 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') -- 2.25.1