Laravel: Enable Sentry user account be used in multiple computers

后端 未结 2 2095
醉话见心
醉话见心 2021-02-04 10:48

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 us

2条回答
  •  耶瑟儿~
    2021-02-04 11:40

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

    /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

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

提交回复
热议问题