繁体   English   中英

Laravel 5.2-用户仅在成功重定向登录后才能登录,一旦执行操作,用户将不再登录

[英]Laravel 5.2 - user is logged in only after successfull login redirect, once I do action user is not more logged in

我现成使用Laravel 5.2和Laravel身份验证 这是我的步骤:1)安装laravel 2)php artisan迁移3)php artisan make:auth

一切准备就绪,至少应该准备好……

比我打开localhost / project / public

a)按注册链接,注册新帐户,如果成功,它将重定向到/ home并告诉我已登录并显示我的用户名。 b)但是,一旦我单击了另一个链接(例如,重定向到/的“主页”按钮),该用户便不再登录。并且由于我没有登录,所以我可以看到“登录”和“注册”链接,但是它们被重定向到/ home符合预期。

我提到如果我在AuthController中对此行进行注释(即使我已登录也允许访问登录页面)

public function __construct()
{
    //$this->middleware('guest', ['except' => 'logout']);
}

在步骤b)之后,使用此注释行,我按Login或Register链接,然后...用户再次登录。。非常奇怪的行为。 如果我打开http:// localhost / project / public / home ,则行为相同,它表示我已登录。

从routes.php文件生成的代码:

Route::group(['middleware' => 'web'], function () {
Route::auth();

Route::get('/home', 'HomeController@index'); });

有谁知道如何解决这个问题?

因此,从本质上讲,这是我的routes.php文件的外观,它可以完美运行:

<?php

/*
|--------------------------------------------------------------------------
| 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.
|
*/



/*
|--------------------------------------------------------------------------
| 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('/', function () {
        return view('welcome');
    });

    Route::get('/home', 'HomeController@index');
});

暂无
暂无

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

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