ユーザーのログイン試行を検出して、ユーザーのアカウントをロックすることを決定する Auth.Attempt イベント ハンドラー クラスがあります。ただし、ユーザーをフラッシュ メッセージでログイン ページにリダイレクトしようとしたところ、リダイレクトが機能しないことがわかりました。まだ次のステップに進んでいます。イベントのプロセスを中断し、カスタムの警告メッセージを表示したいと考えています。誰でも私を助けることができますか?どうもありがとう。
私のイベントハンドラ:
namespace MyApp\Handlers\Security;
use DB;
use Session;
use Redirect;
class LoginHandler
{
/**
* Maximum attempts
* If user tries to login but failed more than this number, User account will be locked
*
* @var integer
*/
private $max_attemtps;
/**
* Maximum attempts per IP
* If an IP / Device tries to login but failed more than this number, the IP will be blocked
*
* @var integer
*/
private $ip_max_attempts;
public function __construct()
{
$this->max_attempts = 10;
$this->ip_max_attempts = 5;
}
public function onLoginAttempt($data)
{
//detection process.......
// if login attempts more than max attempts
return Redirect::to('/')->with('message', 'Your account has been locked.');
}
}
今私がこれをやっている方法は以下のようなものです:
Session::flash('message', 'Your account has been locked.');
header('Location: '.URL::to('/'));
それは機能しますが、それが完璧な方法であるかどうかはわかりません。