getIsGuest()) { return null; } /** @var IdentityInterface $identity */ $identity = $this->getIdentity(); if (!$identity instanceof JwtIdentity) { return null; } $sessionId = $identity->getToken()->getClaim('jti', false); if ($sessionId === false) { return null; } return AccountSession::findOne($sessionId); } public function terminateSessions(Account $account, int $mode = 0): void { $currentSession = null; if ($mode & self::KEEP_CURRENT_SESSION) { $currentSession = $this->getActiveSession(); } if (!($mode & self::KEEP_SITE_SESSIONS)) { foreach ($account->sessions as $session) { if ($currentSession === null || $currentSession->id !== $session->id) { $session->delete(); } } } if (!($mode & self::KEEP_MINECRAFT_SESSIONS)) { /** @var \common\models\OauthSession|null $minecraftSession */ $minecraftSession = $account->getOauthSessions() ->andWhere(['client_id' => OauthClient::UNAUTHORIZED_MINECRAFT_GAME_LAUNCHER]) ->one(); if ($minecraftSession !== null) { $minecraftSession->revoked_at = time(); Assert::true($minecraftSession->save()); } foreach ($account->minecraftAccessKeys as $minecraftAccessKey) { $minecraftAccessKey->delete(); } } } }