From 35705447c285d0c156db80fdf6fc5343686db94c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Lahmann?= <lahmann@ub.uni-leipzig.de>
Date: Thu, 25 Feb 2016 10:03:48 +0100
Subject: [PATCH] * bugfix in PAIA session handling

---
 module/finc/src/finc/ILS/Driver/FincILS.php | 2 +-
 module/finc/src/finc/ILS/Driver/PAIA.php    | 8 +++-----
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/module/finc/src/finc/ILS/Driver/FincILS.php b/module/finc/src/finc/ILS/Driver/FincILS.php
index 3b0af8362e9..7a3cdb66a60 100644
--- a/module/finc/src/finc/ILS/Driver/FincILS.php
+++ b/module/finc/src/finc/ILS/Driver/FincILS.php
@@ -233,7 +233,7 @@ class FincILS extends PAIA implements LoggerAwareInterface
 
             // if we already have a session with access_token and patron id, try to get
             // patron info with session data
-            if (isset($this->session->expires) && microtime() < $this->session->expires) {
+            if (isset($this->session->expires) && $this->session->expires > time()) {
                 try {
                     return $enrichUserDetails(
                         $this->paiaGetUserDetails(($this->session->patron === 'root' ? $username : $this->session->patron)),
diff --git a/module/finc/src/finc/ILS/Driver/PAIA.php b/module/finc/src/finc/ILS/Driver/PAIA.php
index eb43c382e16..29b4aafe98d 100644
--- a/module/finc/src/finc/ILS/Driver/PAIA.php
+++ b/module/finc/src/finc/ILS/Driver/PAIA.php
@@ -608,9 +608,7 @@ class PAIA extends DAIA implements
 
         // if we already have a session with access_token and patron id, try to get
         // patron info with session data
-        if (isset($this->session->expires)
-            && microtime() < $this->session->expires
-        ) {
+        if (isset($this->session->expires) && $this->session->expires > time()) {
             try {
                 return $enrichUserDetails(
                     $this->paiaGetUserDetails($this->session->patron),
@@ -1295,8 +1293,8 @@ class PAIA extends DAIA implements
                 = isset($responseArray['scope'])
                     ? explode(' ', $responseArray['scope']) : null;
             $this->session->expires
-                = isset($responseArray['expires'])
-                    ? (microtime() + ($responseArray['expires']*1000)) : null;
+                = isset($responseArray['expires_in'])
+                    ? (time() + ($responseArray['expires_in'])) : null;
 
             return true;
         }
-- 
GitLab