繁体   English   中英

Laravel 5.2用户登录由于某种原因重定向回登录

[英]Laravel 5.2 user login redirects back to login for some reason

我有一个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');
});

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

protected $redirectAfterLogout = '/login'

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

Route::auth();
Route::get('logout', 'Auth\AuthController@customLogout'); 

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM