##// END OF EJS Templates
authn: Fix form validation of authentication plugins....
johbo -
r102:1a9dcffb default
parent child Browse files
Show More
@@ -474,12 +474,7 b' def loadplugin(plugin_id):'
474 """
474 """
475 Loads and returns an instantiated authentication plugin.
475 Loads and returns an instantiated authentication plugin.
476 Returns the RhodeCodeAuthPluginBase subclass on success,
476 Returns the RhodeCodeAuthPluginBase subclass on success,
477 raises exceptions on failure.
477 or None on failure.
478
479 raises:
480 KeyError -- if no plugin available with given name
481 TypeError -- if the RhodeCodeAuthPlugin is not a subclass of
482 ours RhodeCodeAuthPluginBase
483 """
478 """
484 # TODO: Disusing pyramids thread locals to retrieve the registry.
479 # TODO: Disusing pyramids thread locals to retrieve the registry.
485 authn_registry = get_current_registry().getUtility(IAuthnPluginRegistry)
480 authn_registry = get_current_registry().getUtility(IAuthnPluginRegistry)
@@ -995,18 +995,19 b' def ValidAuthPlugins():'
995 from rhodecode.authentication.base import loadplugin
995 from rhodecode.authentication.base import loadplugin
996 module_list = value
996 module_list = value
997 unique_names = {}
997 unique_names = {}
998 try:
998 for module in module_list:
999 for module in module_list:
999 plugin = loadplugin(module)
1000 plugin = loadplugin(module)
1000 if plugin is None:
1001 plugin_name = plugin.name
1001 raise formencode.Invalid(
1002 if plugin_name in unique_names:
1002 _("Can't find plugin with id '{}'".format(module)),
1003 msg = M(self, 'import_duplicate', state,
1003 value, state)
1004 loaded=unique_names[plugin_name],
1004 plugin_name = plugin.name
1005 next_to_load=plugin_name)
1005 if plugin_name in unique_names:
1006 raise formencode.Invalid(msg, value, state)
1006 msg = M(self, 'import_duplicate', state,
1007 unique_names[plugin_name] = plugin
1007 loaded=unique_names[plugin_name],
1008 except (KeyError, AttributeError, TypeError) as e:
1008 next_to_load=plugin_name)
1009 raise formencode.Invalid(str(e), value, state)
1009 raise formencode.Invalid(msg, value, state)
1010 unique_names[plugin_name] = plugin
1010
1011
1011 return _validator
1012 return _validator
1012
1013
General Comments 0
You need to be logged in to leave comments. Login now