1

我有一个 Laravel 5.2 应用程序并使用了 artisan make:auth 命令。一切都正确生成,我更改了我的表名并设法注册。然后我尝试登录,但我不断被发送回登录页面。如果我故意输入不正确的凭据,我会收到一个错误,因此我知道我的凭据是正确的并且 Laravel 正在与数据库通信。我只是不知道为什么我一直回到登录页面。任何人都可以帮忙吗?我在下面发布了我的路线:

Route::auth();


Route::group(['middleware' => 'auth'], function () {
    Route::post('entity/process', 'EntityController@process');
    Route::get('entity/form/{subCategoryID}/{id?}', 'EntityController@viewForm');
    Route::get('entity/delete/{id}', 'EntityController@delete');
    Route::get('/viewList/{masterCategoryID}/{subCategoryID}', 'EntityController@viewList');
    Route::get('/viewCategories', 'MasterCategoryController@viewAll');

  Route::get('/', 'MasterCategoryController@viewAll');
});
4

2 回答 2

0

解决方案 1:在 App\Http\Controllers\Auth\AuthController 中更改此变量

protected $redirectAfterLogout = '/login'

解决方案 2:在 AuthController 中编写自己的 customLogout 方法。然后像这样覆盖默认注销路由

Route::auth();
Route::get('logout', 'Auth\AuthController@customLogout'); 
于 2016-08-14T19:31:29.837 回答
0

进一步调查后,我发现我的用户表的数据库 ID 字段为空,并且未设置为自动递增。我将其更改为 1 并启用自动增量,然后一切都按预期工作。感谢大家的帮助。

于 2016-08-16T11:30:29.940 回答