i can't login with Auth
in laravel
i got an error NotFoundHttpException
my form for login
<form id="login-form" method="POST" action="{{ route('login') }}">
{{ csrf_field() }}
My file Router.php
public function auth(){
// Authentication Routes...
$this->get('login', 'Auth\LoginController@showLoginForm')->name('login');
$this->post('login', 'Auth\LoginController@login');
$this->post('logout', 'Auth\LoginController@logout')->name('logout');
}
My route:
Route::group(['middleware' => ['auth']], function () {
Route::get('home', 'NavmenuController@menuright')->name('home');
}
Auth::routes();
Route::group(['middleware' => ['guest']], function () {
Route::get('/', function () {
return view('auth.login');
});
});
Make login
for post to named route. Change from
$this->post('login', 'Auth\LoginController@login');
to
$this->post('login', 'Auth\LoginController@login')->name('login');
$this->post('login', 'Auth\LoginController@login');
where is the named route assign?? change to this.
$this->post('login', 'Auth\LoginController@login')->name('post_login');
and in your form add this
<form id="login-form" method="POST" action="{{ route('post_login') }}">
If you use the native Auth of laravel then just add this line in routes.php it will handle all routes of authentications
Auth::routes();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.