Laravel:启用Sentry用户帐户可在多台计算机中使用 [英] Laravel: Enable Sentry user account be used in multiple computers

查看:134
本文介绍了Laravel:启用Sentry用户帐户可在多台计算机中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在L4中使用Sentry时,是否可以在多个计算机上同时使用一个帐户?现在,Sentry会在另一台计算机上使用同一帐户时注销用户.

While using Sentry in L4, is it possible to make an account be used in multiple computers at the same time? Right now, Sentry logs out the user the moment the same account is used in another computer.

现在,我正在尝试使该 not 发生,并使两个用户同时登录.我知道用户注销时这是一种安全功能,但是我项目的情况不是您所说的 normal .

Right now I'm trying for that not to happen and keep both users logged in at the same time. I know that it's a security feature when a user gets logged out, but my project's circumstances aren't what you'd call normal.

推荐答案

对Nico Kaag的回答和spamoom注释的实现的扩展:

Extension to Nico Kaag's answer and implementation of spamoom's comment:

/app/config/packages/cartalyst/sentry/config.php

/app/config/packages/cartalyst/sentry/config.php

...
    // Modify users array to point to custom model.    

'users' => array(
    'model' => 'User',
    'login_attribute' => 'email',
),    

...

/app/models/User.php

/app/models/User.php

use Cartalyst\Sentry\Users\Eloquent\User as SentryUser;

class User extends SentryUser
{

    ...

    ...

    // Override the SentryUser getPersistCode method.

    public function getPersistCode()
    {
        if (!$this->persist_code)
        {
            $this->persist_code = $this->getRandomString();

            // Our code got hashed
            $persistCode = $this->persist_code;

            $this->save();

            return $persistCode;            
        }
        return $this->persist_code;
    }
}

这篇关于Laravel:启用Sentry用户帐户可在多台计算机中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆