1
0
mirror of https://github.com/delight-im/PHP-Auth.git synced 2025-08-05 07:37:25 +02:00

Implement method 'getRememberDirectiveExpiry' in class 'Auth'

This commit is contained in:
Marco
2018-03-24 23:09:18 +01:00
parent 29afbdfc93
commit 9848082bbb

View File

@@ -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;
}
}