Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/roundcube/roundcubemail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <thomas@roundcube.net>2021-12-28 19:21:11 +0300
committerThomas Bruederli <thomas@roundcube.net>2021-12-28 19:22:19 +0300
commit841bead50a930aa304912df52b2dee2dea0abf47 (patch)
treecea4a21dde50ee10a97d134313635d63493d716e
parent6564b7b32c5f7286300bb59a39a3159f825dc223 (diff)
Refresh oauth access token in 'refresh' plugin hook (#8224)
-rw-r--r--program/include/rcmail_oauth.php17
1 files changed, 16 insertions, 1 deletions
diff --git a/program/include/rcmail_oauth.php b/program/include/rcmail_oauth.php
index 7b26509be..61a8b638e 100644
--- a/program/include/rcmail_oauth.php
+++ b/program/include/rcmail_oauth.php
@@ -97,6 +97,7 @@ class rcmail_oauth
$this->rcmail->plugins->register_hook('logout_after', [$this, 'logout_after']);
$this->rcmail->plugins->register_hook('login_failed', [$this, 'login_failed']);
$this->rcmail->plugins->register_hook('unauthenticated', [$this, 'unauthenticated']);
+ $this->rcmail->plugins->register_hook('refresh', [$this, 'refresh']);
}
}
@@ -450,7 +451,7 @@ class rcmail_oauth
*/
protected function check_token_validity($token)
{
- if ($token['expires'] < time() && isset($token['refresh_token'])) {
+ if ($token['expires'] < time() && isset($token['refresh_token']) && empty($this->last_error)) {
$this->refresh_access_token($token);
}
}
@@ -558,4 +559,18 @@ class rcmail_oauth
return $options;
}
+
+
+ /**
+ * Callback for 'refresh' hook
+ *
+ * @param array $options
+ * @return void
+ */
+ public function refresh($options)
+ {
+ if (isset($_SESSION['oauth_token'])) {
+ $this->check_token_validity($_SESSION['oauth_token']);
+ }
+ }
}