What is the login blocker service?
The login blocker service can be used to block customers from logging in based on criteria.
For example, you might want to blacklist certain IPs.
First, define a setting to store blacklisted IPs:
\Aero\Common\Facades\Settings::group('customers', static function (\Aero\Common\Settings\SettingGroup $group) {
$group->array('blocked_ip_addresses');
});
Then add a login blocker to check if the customer IP is blocked:
\Aero\Common\Facades\LoginBlocker::add(function (\Aero\Account\Models\Customer $customer) {
if (in_array(request()->ip(), setting('customers.blocked_ip_addresses')) {
return __('Blocked due to suspicious activity');
}
});
Returning a string means that they customer will be blocked from logging in and that string will be displayed.