I need to check the status of the client (user data), if it is not active then ignore the login to the system
Asked
Active
Viewed 214 times
2 Answers
1
You can rewrite the customer LoginPost plugin
Create a di.xml file app/code/Vendor/Module/etc/di.xml file
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Customer\Controller\Account\LoginPost">
<plugin name="customer_login_plugin" type="Vendor\Module\Plugin\Customer\LoginPost" sortOrder="10" disabled="false"/>
</type>
</config>
Create a Plugin file app/code/Vendor/Module/Plugin/Customer/LoginPost.php
<?php
namespace Vendor\Module\Plugin\Customer;
class LoginPost
{
public function __construct(
\Magento\Framework\App\Action\Context $context
) {
$this->_request = $context->getRequest();
$this->_response = $context->getResponse();
}
public function aroundExecute(\Magento\Customer\Controller\Account\LoginPost $subject, $proceed)
{
$login = $this->_request->getPost('login');
// before login check condition
$returnValue = $proceed();
// after login check condition
return $returnValue;
}
}
Mohit Rane
- 1,955
- 1
- 13
- 47
0
This thread may help, you need to check if user is login or not. Than you can set your logic on basic of login(active) or not-logged user.
Muhammad Ayaz
- 452
- 3
- 11