简体   繁体   English

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

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

I have a Laravel 5.2 app and have used the artisan make:auth command. 我有一个Laravel 5.2应用程序,并使用了artisan make:auth命令。 Everything was generated correctly, I changed my table name and managed to register. 一切都是正确生成的,我改变了我的表名并设法注册。 I then tried to login but I'm continually sent back to the login page. 然后我尝试登录,但我不断被送回登录页面。 If I put incorrect credentials in on purpose, I get an error so I know my credentials are correct and that Laravel is communicating with the database. 如果我故意放入不正确的凭据,我会收到错误,因此我知道我的凭据是正确的,并且Laravel正在与数据库进行通信。 I just have no idea why I keep getting back to the login page. 我只是不知道为什么我一直回到登录页面。 Can anyone help? 有人可以帮忙吗? I have posted my routes below: 我在下面发布了我的路线:

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');
});

Solution 1 : Change this variable in App\\Http\\Controllers\\Auth\\AuthController 解决方案1 :在App \\ Http \\ Controllers \\ Auth \\ AuthController中更改此变量

protected $redirectAfterLogout = '/login'

Solution 2 : Write your own customLogout method in AuthController. 解决方案2 :在AuthController中编写自己的customLogout方法。 Then override default logout route like this 然后像这样覆盖默认的注销路由

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

After investigating further I found that the database ID field for my users table was null and was not set to auto increment. 在进一步调查后,我发现我的users表的数据库ID字段为null,并且未设置为自动增量。 I changed it to 1 and enabled auto increment then everything worked as expected. 我将其更改为1并启用自动增量,然后一切按预期工作。 Thanks for everyone's help. 谢谢大家的帮助。

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

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