我只有在用户通过身份验证后才能访问此受保护的路由:
Route::get('/checkout', [
'middleware' => 'auth',
'uses' => 'Front@checkout'
]);
其他路线是:
// Authentication routes...
Route::get('auth/login', 'Front@login');
Route::post('auth/login', 'Front@authenticate');
Route::get('auth/logout', 'Front@logout');
// Registration routes...
Route::post('/register', 'Front@register');
我的控制器是:
<?php
namespace App\Http\Controllers;
use Request;
use Redirect;
use App\User;
use Illuminate\Support\Facades\Auth;
use App\Http\Controllers\Controller;
class Front extends Controller {
public function register() {
if (Request::isMethod('post')) {
User::create([
'name' => Request::get('name'),
'email' => Request::get('email'),
'password' => bcrypt(Request::get('password')),
]);
}
return Redirect::away('auth/login');
}
public function authenticate() {
if (Auth::attempt(['email' => Request::get('email'), 'password' => Request::get('password')])) {
return redirect()->intended('/checkout');
} else {
return view('auth/loginerror', array('title' => 'Welcome', 'description' => '', 'page' => 'home'));
}
}
public function login() {
return view('auth/login', array('page' => 'home'));
}
public function checkout() {
return view('contactme', array('page' => 'home'));
}
public function logout() {
Auth::logout();
return Redirect::away('auth/login');
}
}
路线中的这个错误怎么样?
RouteCollection.php第161行中的NotFoundHttpException: