1
0
mirror of https://github.com/delight-im/PHP-Auth.git synced 2025-07-30 21:00:13 +02:00

Permit restriction to selector in 'deleteRememberDirectiveForUserById'

This commit is contained in:
Marco
2018-03-24 23:13:04 +01:00
parent 9848082bbb
commit 62270a2c48
2 changed files with 13 additions and 4 deletions

View File

@@ -454,8 +454,8 @@ final class Auth extends UserManager {
$this->setRememberCookie($selector, $token, $expires);
}
protected function deleteRememberDirectiveForUserById($userId) {
parent::deleteRememberDirectiveForUserById($userId);
protected function deleteRememberDirectiveForUserById($userId, $selector = null) {
parent::deleteRememberDirectiveForUserById($userId, $selector);
$this->setRememberCookie(null, null, \time() - 3600);
}

View File

@@ -371,13 +371,22 @@ abstract class UserManager {
* Clears an existing directive that keeps the user logged in ("remember me")
*
* @param int $userId the ID of the user who shouldn't be kept signed in anymore
* @param string $selector (optional) the selector which the deletion should be restricted to
* @throws AuthError if an internal problem occurred (do *not* catch)
*/
protected function deleteRememberDirectiveForUserById($userId) {
protected function deleteRememberDirectiveForUserById($userId, $selector = null) {
$whereMappings = [];
if (isset($selector)) {
$whereMappings['selector'] = (string) $selector;
}
$whereMappings['user'] = (int) $userId;
try {
$this->db->delete(
$this->dbTablePrefix . 'users_remembered',
[ 'user' => $userId ]
$whereMappings
);
}
catch (Error $e) {