From 3ae1769256a627c7410c5d2d990e2abc9c76c17c Mon Sep 17 00:00:00 2001 From: Marco Date: Sun, 25 Mar 2018 00:28:21 +0100 Subject: [PATCH] Implement method 'logOutEverywhere' in class 'Auth' --- src/Auth.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Auth.php b/src/Auth.php index e2e6b62..b7d8d37 100644 --- a/src/Auth.php +++ b/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 *