MDL-56159 webservice: Tolerate exceptions in the get_autologin_key ws

This commit is contained in:
Juan Leyva 2016-09-28 11:20:09 +01:00
parent 80e0f0b85b
commit 43d8e805bb

View File

@ -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 {
)
);
}
}
}