From b4584de9c79f995c819fa0d4d3973277bd5db388 Mon Sep 17 00:00:00 2001 From: Victor Saisa Lopez Date: Tue, 21 Apr 2015 11:15:39 -0400 Subject: [PATCH] PM-00000 "Eliminar los Access y Refresh Token expirados" SOLVED Issue: Eliminar los Access y Refresh Token expirados Cause: Nuevo requerimiento de funciones Solution: Se estan eliminando los Access y Refresh Token expirados al hacer un request al End-point: POST /{workspace}/oauth2/token --- .../engine/src/ProcessMaker/Services/OAuth2/PmPdo.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/workflow/engine/src/ProcessMaker/Services/OAuth2/PmPdo.php b/workflow/engine/src/ProcessMaker/Services/OAuth2/PmPdo.php index 966b4b05a..efdf78e59 100644 --- a/workflow/engine/src/ProcessMaker/Services/OAuth2/PmPdo.php +++ b/workflow/engine/src/ProcessMaker/Services/OAuth2/PmPdo.php @@ -116,6 +116,12 @@ class PmPdo implements \OAuth2\Storage\AuthorizationCodeInterface, public function setAccessToken($access_token, $client_id, $user_id, $expires, $scope = null) { + //Delete expired Access and Refresh Token + foreach (array($this->config["access_token_table"], $this->config["refresh_token_table"]) as $value) { + $stmt = $this->db->prepare(sprintf("DELETE FROM %s WHERE EXPIRES < %s", $value, "'" . date("Y-m-d H:i:s") . "'")); + $result = $stmt->execute(); + } + // convert expires to datestring $expires = date('Y-m-d H:i:s', $expires); @@ -177,10 +183,8 @@ class PmPdo implements \OAuth2\Storage\AuthorizationCodeInterface, $access_token->load($token); $stmt = $this->db->prepare(sprintf('DELETE FROM %s WHERE ACCESS_TOKEN = :token', $this->config['access_token_table'])); - $stmt->execute(compact('token')); - $stmt = $this->db->prepare(sprintf("DELETE FROM %s WHERE EXPIRES < %s", $this->config["refresh_token_table"], "'" . date("Y-m-d H:i:s") . "'")); - return $stmt->execute(compact('token')); + return $stmt->execute(compact("token")); } /* OAuth2_Storage_UserCredentialsInterface */