mirror of
https://github.com/delight-im/PHP-Auth.git
synced 2025-08-02 22:27:30 +02:00
Move essence of 'deleteRememberDirectiveForUserById' to 'UserManager'
This commit is contained in:
18
src/Auth.php
18
src/Auth.php
@@ -439,22 +439,8 @@ final class Auth extends UserManager {
|
|||||||
$this->setRememberCookie($selector, $token, $expires);
|
$this->setRememberCookie($selector, $token, $expires);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected function deleteRememberDirectiveForUserById($userId) {
|
||||||
* Clears an existing directive that keeps the user logged in ("remember me")
|
parent::deleteRememberDirectiveForUserById($userId);
|
||||||
*
|
|
||||||
* @param int $userId the ID of the user who shouldn't be kept signed in anymore
|
|
||||||
* @throws AuthError if an internal problem occurred (do *not* catch)
|
|
||||||
*/
|
|
||||||
private function deleteRememberDirectiveForUserById($userId) {
|
|
||||||
try {
|
|
||||||
$this->db->delete(
|
|
||||||
$this->dbTablePrefix . 'users_remembered',
|
|
||||||
[ 'user' => $userId ]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
catch (Error $e) {
|
|
||||||
throw new DatabaseError();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->setRememberCookie(null, null, \time() - 3600);
|
$this->setRememberCookie(null, null, \time() - 3600);
|
||||||
}
|
}
|
||||||
|
@@ -358,4 +358,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
|
||||||
|
* @throws AuthError if an internal problem occurred (do *not* catch)
|
||||||
|
*/
|
||||||
|
protected function deleteRememberDirectiveForUserById($userId) {
|
||||||
|
try {
|
||||||
|
$this->db->delete(
|
||||||
|
$this->dbTablePrefix . 'users_remembered',
|
||||||
|
[ 'user' => $userId ]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
catch (Error $e) {
|
||||||
|
throw new DatabaseError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user