Support the ongoing development of Laravel.io →
Authentication
Last updated 2 years ago.
0

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'));
    });
Last updated 9 years ago.
0

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();
}
0

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

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.