I have an Auth.Attempt event handler class that I found that user login attempts have decided to lock the user account. However, when I tried to redirect the user to the login page with the flash message, I found that the redirect did not work, it still continues the next step. I want to interrupt the process in the event and provide my own warning message. Can someone help me? Many thanks.
My event handler:
namespace MyApp\Handlers\Security;
use DB;
use Session;
use Redirect;
class LoginHandler
{
private $max_attemtps;
private $ip_max_attempts;
public function __construct()
{
$this->max_attempts = 10;
$this->ip_max_attempts = 5;
}
public function onLoginAttempt($data)
{
return Redirect::to('/')->with('message', 'Your account has been locked.');
}
}
Now, the way I do this is as follows:
Session::flash('message', 'Your account has been locked.');
header('Location: '.URL::to('/'));
This works, but I'm not sure if this is the perfect way to do this.