Customize Login routes in Laravel 5.3

1

Hi, I have a problem with Login routing with the php artisan make: auth method that generates everything you need From now on it's quite difficult for me to join the project I was doing to this login and its views. But it does not let me change the prefedinida route to one that I want

So they come by default:

Route::get('login', 'Auth\LoginController@showLoginForm')->name('login');

Route::post('login', 'Auth\LoginController@login');

Route::post('logout', 'Auth\LoginController@logout');

Thus I customize

Route::get('admin/auth/login', 'Auth\LoginController@showLoginForm')->name('login');

Route::post('admin/auth/login', 'Auth\LoginController@login');

Route::post('admin/auth/logout', 'Auth\LoginController@logout');

LoginController.php

use AuthenticatesUsers;


protected $redirectTo = '/';


public function __construct()
{
    $this->middleware('guest', ['except' => 'logout']);
}

public function showLoginForm()
{
    return view('admin.auth.login'); //tambien cambie de dir la carp auth
}

public function logout(Request $request)
{
    $this->guard()->logout();

    $request->session()->flush();

    $request->session()->regenerate();

    //return view('inicio');
    return redirect('/');
}

When I enter the login route, and log in I miss this error:

  

NotFoundHttpException in RouteCollection.php line 161: ...

    
asked by Cidius 09.09.2016 в 05:31
source

1 answer

3

Indeed, I failed to correct the login.blade.php form for the default provided by Laravel. By placing the correct URL, it works as expected.

form class="form-horizontal" role="form" method="POST" action="{{ url('admin/auth/login') }}"> {{ csrf_field() }}

Remember, there is also the logout form that happens the same.

    
answered by 09.09.2016 / 15:39
source