I'm using Laravel 4's App::error
class to catch Sentry exceptions throughout my application and pass the data back to the template using the withErrors()
function.
Simple route:
routes.php
Route::post('/login...
...
$credentials = array(
'email' => Input::get('email'),
'password' => Input::get('password')
);
$user = Sentry::authenticate($credentials);
// Exception thrown...
Then to catch the exceptions:
exceptions.php
App::error(function(Cartalyst\Sentry\Users\WrongPasswordException $e) {
return Redirect::back()->withErrors(array('failed' => 'Email or password is incorrect'))->withInput();
});
In the view:
/views/login/login.blade.php
@if ($errors->has('failed'))
<strong>{{ $errors->first('failed') }}</strong>
@endif
The problem is, when you refresh the page after a failed log in attempt these errors persist so you see them twice. Refreshing a second time, they have cleared. Same goes for the input (passed with withInput()
).
If the errors are caught within the route (rather than in App:error
), everything works as normal. Should I be clearing the stored data manually using the App::error
methods?