Implementation
app/code/Magento/Security/Model/ResourceModel/AdminSessionInfo.php
/**
* Update status by user ID
*
* @param int $status
* @param int $userId
* @param array $withStatuses
* @param array $excludedSessionIds
* @param int|null $updateOlderThen
* @return int The number of affected rows.
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function updateStatusByUserId(
$status,
$userId,
array $withStatuses = [],
array $excludedSessionIds = [],
$updateOlderThen = null
) {
$whereStatement = [
'updated_at > ?' => $this->dateTime->formatDate($updateOlderThen),
'user_id = ?' => (int) $userId,
];
if (!empty($excludedSessionIds)) {
$whereStatement['session_id NOT IN (?)'] = $excludedSessionIds;
}
if (!empty($withStatuses)) {
$whereStatement['status IN (?)'] = $withStatuses;
}
return $this->getConnection()->update(
$this->getMainTable(),
['status' => (int) $status],
$whereStatement
);
}