我遇到了Laravel 5.2登录和注册的问题.我在这里使用Laravel 5.2默认login.blade.PHP和register.blade.PHP.All事情进展顺利但是当我试图注册任何用户并填写表格然后提交它不会在数据库中插入任何数据,并且在浏览器窗口中显示相同的页面.虽然我已经使调试成立,但浏览器没有显示任何错误.
这是我的routes.PHP:
<?PHP
use App\Member;
use Illuminate\Http\Request;
/*
|--------------------------------------------------------------------------
| Routes File
|--------------------------------------------------------------------------
|
| Here is where you will register all of the routes in an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
return view('welcome');
});
Route::get('/home', function () {
return view('home');
});
Route::get('/members', 'MemberController@index');
Route::post('/member', 'MemberController@store');
Route::delete('/member/{member}', 'MemberController@destroy');
// Authentication Routes...
Route::get('auth/login', 'Auth\AuthController@getLogin');
Route::post('auth/login', 'Auth\AuthController@postLogin');
Route::get('auth/logout', 'Auth\AuthController@logout');
// Registration Routes...
Route::get('auth/register', 'Auth\AuthController@getRegister');
Route::post('auth/register', 'Auth\AuthController@postRegister');
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/
Route::group(['middleware' => ['web']], function () {
//
});
Route::group(['middleware' => 'web'], function () {
Route::auth();
Route::get('/home', 'HomeController@index');
});
我在Stackoverflow中已经阅读了很多问题.但是所有问题都无法解决我的问题.这里是这些问题的一些链接:
> Can not login and register in laravel 5.1
> Laravel 5.2 /login & /register not working
> Laravel 5.2 Authentication – How can I show logged in user’s name and the logout link in every page?
如果你需要任何文件找到解决方案,请告诉我.然后我会在这里提供.
解决方法:
你已经阅读了答案,你只是没有正确应用它. Auth需要会话.任何需要会话信息的路由都应该在Web中间件组中.
现在,您的成员,成员,身份验证/登录,身份验证/注销,身份验证/注册,“主页”和/路由都在Web中间件组之外,因此它们都不会提供会话信息(这意味着它们都不可用)将显示用户登录).