From 9848082bbb61f99475fdc4c2b46a14e50a5e5204 Mon Sep 17 00:00:00 2001 From: Marco Date: Sat, 24 Mar 2018 23:09:18 +0100 Subject: [PATCH] Implement method 'getRememberDirectiveExpiry' in class 'Auth' --- src/Auth.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/Auth.php b/src/Auth.php index a8c2115..6963c52 100644 --- a/src/Auth.php +++ b/src/Auth.php @@ -1793,4 +1793,37 @@ final class Auth extends UserManager { } } + /** + * Returns the expiry date of a potential locally existing remember directive + * + * @return int|null + */ + private function getRememberDirectiveExpiry() { + // if the user is currently signed in + if ($this->isLoggedIn()) { + // determine the selector of any currently existing remember directive + $existingSelector = $this->getRememberDirectiveSelector(); + + // if there is currently a remember directive whose selector we have just retrieved + if (isset($existingSelector)) { + // fetch the expiry date for the given selector + $existingExpiry = $this->db->selectValue( + 'SELECT expires FROM ' . $this->dbTablePrefix . 'users_remembered WHERE selector = ? AND user = ?', + [ + $existingSelector, + $this->getUserId() + ] + ); + + // if an expiration date has been found + if (isset($existingExpiry)) { + // return the date + return (int) $existingExpiry; + } + } + } + + return null; + } + }