X-Git-Url: http://git.moodle.org/gw?p=moodle.git;a=blobdiff_plain;f=auth%2Foauth2%2Flinkedlogins.php;h=ff9a89f5238506d599fb908f836e0e206b100844;hp=d8f68f142991b64ec357707317875cdf5060e217;hb=2c69d24037089c060b1937425aa4c1d676a2b5d3;hpb=081aad9986449ad0136286a66a0dc79457c47425;ds=sidebyside diff --git a/auth/oauth2/linkedlogins.php b/auth/oauth2/linkedlogins.php index d8f68f14299..ff9a89f5238 100644 --- a/auth/oauth2/linkedlogins.php +++ b/auth/oauth2/linkedlogins.php @@ -58,8 +58,12 @@ if ($action == 'new') { $userinfo = $client->get_userinfo(); if (!empty($userinfo)) { - \auth_oauth2\api::link_login($userinfo, $issuer); - redirect($PAGE->url, get_string('changessaved'), null, \core\output\notification::NOTIFY_SUCCESS); + try { + \auth_oauth2\api::link_login($userinfo, $issuer); + redirect($PAGE->url, get_string('changessaved'), null, \core\output\notification::NOTIFY_SUCCESS); + } catch (Exception $e) { + redirect($PAGE->url, $e->getMessage(), null, \core\output\notification::NOTIFY_ERROR); + } } else { redirect($PAGE->url, get_string('notloggedin', 'auth_oauth2'), null, \core\output\notification::NOTIFY_ERROR); }