From 3e82b7ac3ca7441a54f054e7ecd94e49c8ec49e2 Mon Sep 17 00:00:00 2001 From: Rimas Kudelis Date: Tue, 20 Sep 2016 18:22:07 +0300 Subject: [PATCH] MDL-56082 Expose external authentication methods in login block Unlike the login page, login block currently does not list any configured external auth methods. This makes it practically useless in cases where external auth (e.g. OpenID Connect) is the main login method. This patch adds the necessary bits to make the login block great again. --- blocks/login/block_login.php | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/blocks/login/block_login.php b/blocks/login/block_login.php index 2c4eda4aa72..6f5bab7c0a5 100644 --- a/blocks/login/block_login.php +++ b/blocks/login/block_login.php @@ -32,7 +32,7 @@ class block_login extends block_base { } function get_content () { - global $USER, $CFG, $SESSION; + global $USER, $CFG, $SESSION, $OUTPUT; $wwwroot = ''; $signup = ''; @@ -96,15 +96,32 @@ class block_login extends block_base { $this->content->text .= "\n"; if (!empty($signup)) { - $this->content->footer .= '
'.get_string('startsignup').'
'; + $this->content->text .= '
'.get_string('startsignup').'
'; } if (!empty($forgot)) { - $this->content->footer .= '
'.get_string('forgotaccount').'
'; + $this->content->text .= '
'.get_string('forgotaccount').'
'; + } + + $authsequence = get_enabled_auth_plugins(true); // Get all auths, in sequence. + $potentialidps = array(); + foreach ($authsequence as $authname) { + $authplugin = get_auth_plugin($authname); + $potentialidps = array_merge($potentialidps, $authplugin->loginpage_idp_list(empty($SESSION->wantsurl) ? '' : $SESSION->wantsurl)); + } + + if (!empty($potentialidps)) { + $this->content->text .= '
'; + $this->content->text .= '
' . get_string('potentialidps', 'auth') . '
'; + $this->content->text .= '
'; + foreach ($potentialidps as $idp) { + $this->content->text .= ''; + } + $this->content->text .= '
'; + $this->content->text .= '
'; } } return $this->content; } } - -