From ac8a0c4077cc06c28d74272b813ac5f3ac5047d9 Mon Sep 17 00:00:00 2001 From: David Monllao Date: Fri, 12 May 2017 10:17:06 +0800 Subject: [PATCH] MDL-58905 auth_oauth2: Add plugin enabled checkings --- auth/oauth2/confirm-account.php | 4 ++++ auth/oauth2/confirm-linkedlogin.php | 4 ++++ auth/oauth2/login.php | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/auth/oauth2/confirm-account.php b/auth/oauth2/confirm-account.php index 03e1b76f719..9b4a1298215 100644 --- a/auth/oauth2/confirm-account.php +++ b/auth/oauth2/confirm-account.php @@ -34,6 +34,10 @@ $PAGE->set_context(context_system::instance()); $auth = get_auth_plugin('oauth2'); +if (!\auth_oauth2\api::is_enabled()) { + throw new \moodle_exception('notenabled', 'auth_oauth2'); +} + $confirmed = $auth->user_confirm($username, $usersecret); if ($confirmed == AUTH_CONFIRM_ALREADY) { diff --git a/auth/oauth2/confirm-linkedlogin.php b/auth/oauth2/confirm-linkedlogin.php index 1d0b78e1eb0..a05ba2ae0c1 100644 --- a/auth/oauth2/confirm-linkedlogin.php +++ b/auth/oauth2/confirm-linkedlogin.php @@ -34,6 +34,10 @@ $redirect = optional_param('redirect', '', PARAM_LOCALURL); // Where to redir $PAGE->set_url('/auth/oauth2/confirm-linkedlogin.php'); $PAGE->set_context(context_system::instance()); +if (!\auth_oauth2\api::is_enabled()) { + throw new \moodle_exception('notenabled', 'auth_oauth2'); +} + $confirmed = \auth_oauth2\api::confirm_link_login($userid, $username, $issuerid, $token); if ($confirmed) { diff --git a/auth/oauth2/login.php b/auth/oauth2/login.php index d1d8f79446e..5a9d7e8098a 100644 --- a/auth/oauth2/login.php +++ b/auth/oauth2/login.php @@ -29,6 +29,10 @@ $wantsurl = new moodle_url(optional_param('wantsurl', '', PARAM_URL)); require_sesskey(); +if (!\auth_oauth2\api::is_enabled()) { + throw new \moodle_exception('notenabled', 'auth_oauth2'); +} + $issuer = new \core\oauth2\issuer($issuerid); $returnparams = ['wantsurl' => $wantsurl, 'sesskey' => sesskey(), 'id' => $issuerid]; -- 2.11.4.GIT