From 43d8e805bb973a727b4f9852978e9ec778f07d28 Mon Sep 17 00:00:00 2001 From: Juan Leyva Date: Wed, 28 Sep 2016 11:20:09 +0100 Subject: [PATCH] MDL-56159 webservice: Tolerate exceptions in the get_autologin_key ws --- admin/tool/mobile/classes/external.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/admin/tool/mobile/classes/external.php b/admin/tool/mobile/classes/external.php index 4309100ee4f..e06fe73deed 100644 --- a/admin/tool/mobile/classes/external.php +++ b/admin/tool/mobile/classes/external.php @@ -240,7 +240,22 @@ class external extends external_api { $privatetoken = $params['privatetoken']; $context = context_system::instance(); - self::validate_context($context); + + // We must toletare these two exceptions: forcepasswordchangenotice and usernotfullysetup. + try { + self::validate_context($context); + } catch (Exception $e) { + if ($e instanceof moodle_exception) { + if (($e->errorcode != 'usernotfullysetup') and + ($e->errorcode != 'forcepasswordchangenotice')) { + + // In case we receive a different exception, throw it. + throw $e; + } + } else { + throw $e; + } + } api::check_autologin_prerequisites($USER->id); @@ -293,4 +308,4 @@ class external extends external_api { ) ); } -} \ No newline at end of file +}