Have you watched the laracast on auth?
https://laracasts.com/index/authentication
https://www.youtube.com/results?search_query=laravel+routing
public function postLogin(Request $request)
{
$this->validate($request, [
'email' => 'required', 'password' => 'required',
]);
$credentials = $request->only('email', 'password');
if ($this->auth->attempt($credentials, $request->has('remember')))
{
return redirect($this->redirectPath());
}
//////a redirect///////////////////////////////////////////////////////////
return redirect('/auth/login')
->withInput($request->only('email'))
->withErrors([
'email' => 'These credentials do not match our records.',
]);
}
Auth in route
$router->group(['middleware' => 'auth'], function($router)
{
Route::get('owners', array('uses' => 'PownersController@ownerlist'));
});
Try using this example for Laravel 4.2. For Laravel 5 it can be adapted easily
Routes:
Route::group(['before' => 'auth'],function(){
Route::get('travelexpense', ['uses' => 'TravelController@expense']);
});
Controller
public function expense(){
$input = Input::all();
if (Auth::attempt([ 'user' => $input['user'], 'pass' => $input['pass'] ]){
return View::make('travel.expenses');
}
return Redirect::to('login)->withInput();
}
Thanks.
I found this in the doc: The Redirect::intended function will redirect the user to the URL they were trying to access before being caught by the authentication filter.
This works for me. But i didn't test it properly.
regards markus
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community