I reckon the controller action class related to what you're looking for is Magento\User\Controller\Adminhtml\User\InvalidateToken.php
:
public function execute()
{
if ($userId = $this->getRequest()->getParam('user_id')) {
try {
$this->tokenService->revokeAdminAccessToken($userId);
$this->messageManager->addSuccess(__('You have revoked the user\'s tokens.'));
$this->_redirect('adminhtml/*/edit', ['user_id' => $userId]);
return;
} catch (\Exception $e) {
$this->messageManager->addError($e->getMessage());
$this->_redirect('adminhtml/*/edit', ['user_id' => $userId]);
return;
}
}
$this->messageManager->addError(__('We can\'t find a user to revoke.'));
$this->_redirect('adminhtml/*');
}
It is trigerred by clicking the Force Sign-in button on the user edit page Magento\User\Block\User\Edit.php
:
if (!empty($objId)) {
$deleteConfirmMsg = __("Are you sure you want to revoke the user\'s tokens?");
$this->addButton(
'invalidate',
[
'label' => __('Force Sign-In'),
'class' => 'invalidate-token',
'onclick' => 'deleteConfirm(\'' . $deleteConfirmMsg . '\', \'' . $this->getInvalidateUrl() . '\')',
]
);
}
The function that actually sets the revoked
column to 1 can be found under /Magento/Integration/Model/AdminTokenService.php
:
public function revokeAdminAccessToken($adminId)
{
$tokenCollection = $this->tokenModelCollectionFactory->create()->addFilterByAdminId($adminId);
if ($tokenCollection->getSize() == 0) {
throw new LocalizedException(__('This user has no tokens.'));
}
try {
foreach ($tokenCollection as $token) {
$token->setRevoked(1)->save();
}
} catch (\Exception $e) {
throw new LocalizedException(__('The tokens could not be revoked.'));
}
return true;
}