From 084a42f9f58d3946aa8a42244f6af2db63ddb176 Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Fri, 10 May 2019 15:47:04 +0800 Subject: [PATCH] MDL-65518 badges: Require the issuercontact For Badges V2 we can't use just any email address to issue badges, it needs to be a valid account on the backpack. --- badges/classes/backpack_api.php | 2 +- lib/badgeslib.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/badges/classes/backpack_api.php b/badges/classes/backpack_api.php index e96dd028c50..0916dea4752 100644 --- a/badges/classes/backpack_api.php +++ b/badges/classes/backpack_api.php @@ -91,7 +91,7 @@ class backpack_api { $this->backpackapiurl = $sitebackpack->backpackapiurl; $this->backpackapiversion = $sitebackpack->apiversion; $this->password = $sitebackpack->password; - $this->email = !empty($CFG->badges_defaultissuercontact) ? $CFG->badges_defaultissuercontact : $admin->email; + $this->email = !empty($CFG->badges_defaultissuercontact) ? $CFG->badges_defaultissuercontact : ''; $this->isuserbackpack = false; $this->backpackid = $sitebackpack->id; if (!empty($userbackpack)) { diff --git a/lib/badgeslib.php b/lib/badgeslib.php index b8f856d03b0..986e503f80e 100644 --- a/lib/badgeslib.php +++ b/lib/badgeslib.php @@ -1195,7 +1195,7 @@ function badges_verify_site_backpack() { // Now attempt a login with these credentials. $result = $backpackapi->authenticate(); - if ($result === false || !empty($result->error)) { + if (empty($result) || !empty($result->error)) { $warning = $backpackapi->get_authentication_error(); $params = ['id' => $backpack->id, 'action' => 'edit'];