Skip to content

Login once, logged in everywhere. 在一处登录后,所有设备均显示已登录。 #109

Closed
@moycat

Description

@moycat
  1. Tell us your software version

    Software Version
    PHP 7.2.12
    Swoole 4.2.10-alpha
    Laravel/Lumen 5.7.*
  2. Detail description about this issue(error/log)

    使用 Laravel 内置的用户系统时,只要在一处登录,在其他任何地方访问均显示我已登录,清空 Cookies 也无效。

    我已经按照 这里为什么注释掉了. 我打开注释登录用户才算正常? 有坑吗? #99 使用 jwt 时,auth 获取当前登录用户有问题。 #50 中的描述设置了 config/laravels.php 中的「register_providers」,但是并没有用。按照前一个 issue 提出者所说将 cleanRequest 函数里那两行取消注释,还是这样。

    这个 bug 并不稳定,不能 100% 复现。但它的确存在,用一个从未访问过此网站的手机打开也可能触发。

    我觉得就是那两个 issue 中的相关问题,但我想知道如何修复。

    When I use the built-in user system of Laravel, if I login once, the site shows I am logged in everywhere, even after I cleaned my cookies.

    I have set the "register_providers" in config/laravels.php to the following as mentioned in 这里为什么注释掉了. 我打开注释登录用户才算正常? 有坑吗? #99 and 使用 jwt 时,auth 获取当前登录用户有问题。 #50, but it did no good. Neither did uncommenting the two lines in the cleanRequest function.

    This bug isn't consistent, but it does exists. I have ever used a phone that never visited the site to browse it, and it said I was logged in.

    I think the bug is related to the two issues above. I want to know how to fix it.

    config/laravels.php:

return [
    //......
    'register_providers'       => [
        '\App\Providers\AuthServiceProvider',
        '\Illuminate\Auth\AuthServiceProvider',
        '\Illuminate\Auth\Passwords\PasswordResetServiceProvider',
    ],
    //......
];

image

请求头中没有 cookies,但还是显示已登录。

No cookies passed to server. Still shows logged in.

  1. Give us a reproducible code block and steps

    创建一个最简单的应用:

    1. laravel new test,进入目录,用 composer 安装 laravel-s。
    2. php artisan laravels publish,修改 config/laravels.php
    3. 使用 SQLite 数据库(只是简单起见,用 PostgreSQL 也一样),php artisan migrate
    4. 打开 http://127.0.0.1:5200 注册并登录。
    5. 清除 Cookies / 关闭浏览器,再打开这个站点,依然显示已登录。

    Just create a most simplified application (also the steps to have this bug):

    1. laravel new test and cd into it, install laravel-s via composer.
    2. php artisan laravels publish and modify the config/laravels.php file.
    3. php artisan make:auth to enable the user system.
    4. Change the database to SQLite (just to simplify. using PostgreSQL doesn't help), and php artisan migrate.
    5. Open http://127.0.0.1:5200, register a user, login.
    6. Clean the cookies / close the browser / change the device, re-open the site. It shows you are still online.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions