사용자의 계정을 잠그기로 결정한 사용자의 로그인 시도를 감지하는 Auth.Attempt 이벤트 처리기 클래스가 있습니다. 그러나 플래시 메시지가있는 로그인 페이지로 사용자를 리디렉션하려고 시도했을 때 리디렉션이 작동하지 않는다는 것을 알았지 만 다음 단계로 진행됩니다. 이벤트의 프로세스를 중단하고 사용자 지정 경고 메시지를 보내려고합니다. 누구든지 나를 도울 수 있습니까? 고마워.Laravel Redirect가 이벤트 처리기/수신기에서 작동하지 않습니다.
내 이벤트 핸들러 :
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('/'));
그것은 작동하지만 난 그것을 할 수있는 완벽한 방법이 있는지 모르겠습니다.
왜'리디렉션을 사용합니다'? –
인증을 처리하고 싶지 않기 때문에. 사용자 이름과 암호의 유효성을 검사하기 전에 사용자 로그인 시도를 확인하려고합니다. 사용자의 계정이 잠겨 있거나 IP가 차단 된 경우 프로세스가 종료되고 플래시 메시지가있는 홈 페이지로 리디렉션됩니다. – Jonathan
아니요,'리디렉션 사용 '이 유효한 네임 스페이스입니까? –