mirror of
https://github.com/delight-im/PHP-Auth.git
synced 2025-07-10 19:16:22 +02:00
Implement method 'logOutEverywhere' in class 'Auth'
This commit is contained in:
17
src/Auth.php
17
src/Auth.php
@ -412,6 +412,23 @@ final class Auth extends UserManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the user out in all sessions
|
||||
*
|
||||
* @throws NotLoggedInException if the user is not currently signed in
|
||||
* @throws AuthError if an internal problem occurred (do *not* catch)
|
||||
*/
|
||||
public function logOutEverywhere() {
|
||||
if (!$this->isLoggedIn()) {
|
||||
throw new NotLoggedInException();
|
||||
}
|
||||
|
||||
// schedule a forced logout in all sessions
|
||||
$this->forceLogoutForUserById($this->getUserId());
|
||||
// and immediately apply the logout locally
|
||||
$this->logOut();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys all session data
|
||||
*
|
||||
|
Reference in New Issue
Block a user