Commit 86738f26 authored by Francois Marier's avatar Francois Marier

Make the basic login form optional

By default the login form is needed by every auth plugin however
they can now override this and state that it's not needed.

If there are no usabled/enabled auth plugins that need the standard
username/password login form, then it is no longer displayed.

Note that until bug 904620 is fixed, you cannot remove the Internal
auth plugin (which needs the basic form elements) without a bit of
database surgery.

Bug #905081

Change-Id: If2bc7510a93e3aa365c41b4e3d7f6c3ce782d4c1
Signed-off-by: default avatarFrancois Marier <francois@catalyst.net.nz>
parent 32e74e1b
......@@ -1029,16 +1029,30 @@ function auth_get_login_form() {
),
);
// Get any extra elements from the enabled auth plugins
$extraelements = array();
$showbasicform = false;
$authplugins = auth_get_enabled_auth_plugins();
foreach ($authplugins as $plugin) {
$classname = 'PluginAuth' . ucfirst(strtolower($plugin));
$pluginelements = call_static_method($classname, 'login_form_elements');
if (!empty($pluginelements)) {
$elements = array_merge($elements, $pluginelements);
$extraelements = array_merge($extraelements, $pluginelements);
}
if (call_static_method($classname, 'need_basic_login_form')) {
$showbasicform = true;
}
}
// Replace or supplement the standard login form elements
if ($showbasicform) {
$elements = array_merge($elements, $extraelements);
}
else {
$elements = $extraelements;
}
// The login page is completely transient, and it is smart because it
// remembers the GET and POST data sent to it and resends that on
// afterwards.
......@@ -1648,13 +1662,26 @@ function auth_generate_login_form() {
);
// Get any extra elements from the enabled auth plugins
$extraelements = array();
$showbasicform = false;
$authplugins = auth_get_enabled_auth_plugins();
foreach ($authplugins as $plugin) {
$classname = 'PluginAuth' . ucfirst(strtolower($plugin));
$pluginelements = call_static_method($classname, 'login_form_elements');
if (!empty($pluginelements)) {
$elements = array_merge($elements, $pluginelements);
$extraelements = array_merge($extraelements, $pluginelements);
}
if (call_static_method($classname, 'need_basic_login_form')) {
$showbasicform = true;
}
}
// Replace or supplement the standard login form elements
if ($showbasicform) {
$elements = array_merge($elements, $extraelements);
}
else {
$elements = $extraelements;
}
$loginform = get_login_form_js(pieform(array(
......@@ -1819,4 +1846,12 @@ class PluginAuth extends Plugin {
public static function login_form_js() {
return false;
}
/**
* Can be overridden by plugins that inject the things they need
* in the login form and don't need the standard elements.
*/
public static function need_basic_login_form() {
return true;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment