22 private $moduleDataSetup;
29 \
Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup
31 $this->moduleDataSetup = $moduleDataSetup;
39 $this->moduleDataSetup->getConnection()->startSetup();
41 $this->removeRevokedTokens();
42 $this->removeTokensFromInactiveAdmins();
43 $this->removeTokensFromInactiveCustomers();
45 $this->moduleDataSetup->getConnection()->endSetup();
77 private function removeRevokedTokens()
79 $oauthTokenTable = $this->moduleDataSetup->getTable(
'oauth_token');
81 $where = [
'revoked = ?' => 1];
82 $this->moduleDataSetup->getConnection()->delete($oauthTokenTable, $where);
90 private function removeTokensFromInactiveAdmins()
92 $oauthTokenTable = $this->moduleDataSetup->getTable(
'oauth_token');
93 $adminUserTable = $this->moduleDataSetup->getTable(
'admin_user');
95 $select = $this->moduleDataSetup->getConnection()->select()->from(
97 [
'user_id',
'is_active']
100 $admins = $this->moduleDataSetup->getConnection()->fetchAll(
$select);
101 foreach ($admins as $admin) {
102 if ($admin[
'is_active'] == 0) {
103 $where = [
'admin_id = ?' => (int)$admin[
'user_id']];
104 $this->moduleDataSetup->getConnection()->delete($oauthTokenTable, $where);
114 private function removeTokensFromInactiveCustomers()
116 $oauthTokenTable = $this->moduleDataSetup->getTable(
'oauth_token');
117 $adminUserTable = $this->moduleDataSetup->getTable(
'customer_entity');
119 $select = $this->moduleDataSetup->getConnection()->select()->from(
121 [
'entity_id',
'is_active']
124 $admins = $this->moduleDataSetup->getConnection()->fetchAll(
$select);
125 foreach ($admins as $admin) {
126 if ($admin[
'is_active'] == 0) {
127 $where = [
'customer_id = ?' => (int)$admin[
'entity_id']];
128 $this->moduleDataSetup->getConnection()->delete($oauthTokenTable, $where);
__construct(\Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup)