MDL-59889 oauth2: Remove check for storing new refresh token
authorJan Dageförde <jan.dagefoerde@ercis.uni-muenster.de>
Mon, 21 Aug 2017 13:57:24 +0000 (15:57 +0200)
committerJan Dageförde <jan.dagefoerde@ercis.uni-muenster.de>
Fri, 6 Oct 2017 12:49:17 +0000 (14:49 +0200)
lib/classes/oauth2/client.php

index 07a775d..72baad9 100644 (file)
@@ -215,15 +215,9 @@ class client extends \oauth2_client {
         $this->store_token($accesstoken);
 
         if (isset($r->refresh_token)) {
-            $userinfo = $this->get_userinfo();
-
-            if ($userinfo['email'] == $systemaccount->get('email')) {
-                $systemaccount->set('refreshtoken', $r->refresh_token);
-                $systemaccount->update();
-                $this->refreshtoken = $r->refresh_token;
-            } else {
-                throw new moodle_exception('Attempt to store refresh token for non-system user.');
-            }
+            $systemaccount->set('refreshtoken', $r->refresh_token);
+            $systemaccount->update();
+            $this->refreshtoken = $r->refresh_token;
         }
 
         return true;