I need to redirect the user to a simple informative view when throttling is detected during login.
I have a view called suspended.blade.php
I have set a route
Route::get('/suspended', function(){
return view('suspended');
});
I'm using Cartalyst/Sentinel.
In my login controller I have something like this:
function LoginUser(Request $request){
// some validation stuff...
try {
$user = Sentinel::authenticate($request->all());
} catch (ThrottlingException $e) {
// user inserted too many times a wrong password
return redirect('/suspended');
} catch (NotActivatedgException $e) {
return redirect()->back()->with( ['error' => "Account not active yet."] );
}
// some other stuff...
}
If I emulate trottling I only get an error page, instead of my view.
Why is that?
Thanks
EDIT Following the hints of @PsyLogic I modified my function like that:
function LoginUser(Request $request){
// some validation stuff...
try {
$user = Sentinel::authenticate($request->all());
}
/* remove this part to use the default behaviour described in app\Excpetions\Handler.php */
// catch (ThrottlingException $e) {
// return redirect('/suspended');
// }
catch (NotActivatedgException $e) {
return redirect()->back()->with( ['error' => "Account not active yet."]
);
}
// some other stuff...
}
Still does not work, and shows the Laravel Error Page with all the debug code.
Laravel already has throttle middleware you can just extend it and update the
handle()
methodand update the new middleware in your Handle.php file
or you may keep the original index throttle and add your s
Updated (easy way)
Event those changes won't affect your package, but let's do it with easy way, you can update the
render()
function insideApp\Exceptions\Handler::class
and make a test