diff --git a/.gitignore b/.gitignore index c5735844e3ee..3198f9251adc 100755 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ composer.phar /app/database/*.sqlite /app/storage/meta/services.json /app/config/*/mail.php +/app/config/*/session.php /app/config/*/database.php /app/config/*/app.php public/packages/* @@ -23,9 +24,5 @@ public/uploads/logo.png .siteflow public/assets/.siteflow .settings/settings.json -app/config/packages/schickling/backup/config.php -app/config/packages/fideloper/proxy/config.php -app/storage/dumps/20150619212924.sql -app/config/staging/session.php -app/config/production/session.php -app/config/local/session.php + + diff --git a/app/config/production/session.example.php b/app/config/production/session.example.php index 586da3600ee1..16a3f4c17676 100644 --- a/app/config/production/session.example.php +++ b/app/config/production/session.example.php @@ -137,4 +137,18 @@ 'secure' => false, + + /* + |-------------------------------------------------------------------------- + | Allow multiple logins from different devices at the same time + |-------------------------------------------------------------------------- + | + | By default, if a user logs into an account where someone is already + | logged in, the previous user will be logged out. We recommend leaving + | this set to false for security reasons. + | + */ + + 'multi_login' => false, + ); diff --git a/app/config/staging/session.example.php b/app/config/staging/session.example.php index 586da3600ee1..6f5443b6db11 100644 --- a/app/config/staging/session.example.php +++ b/app/config/staging/session.example.php @@ -135,6 +135,20 @@ | */ - 'secure' => false, + 'secure' => true, + + + /* + |-------------------------------------------------------------------------- + | Allow multiple logins from different devices at the same time + |-------------------------------------------------------------------------- + | + | By default, if a user logs into an account where someone is already + | logged in, the previous user will be logged out. We recommend leaving + | this set to false for security reasons. + | + */ + + 'multi_login' => true, ); diff --git a/app/models/User.php b/app/models/User.php index 79b20606b6bf..e4cd9af58a99 100755 --- a/app/models/User.php +++ b/app/models/User.php @@ -119,5 +119,24 @@ public function scopeGetNotDeleted($query) return $query->whereNull('deleted_at'); } + /** + * Override the SentryUser getPersistCode method for + * multiple logins at one time + **/ + public function getPersistCode() + { + + if (!Config::get('session.multi_login') || (!$this->persist_code)) + { + $this->persist_code = $this->getRandomString(); + + // Our code got hashed + $persistCode = $this->persist_code; + $this->save(); + return $persistCode; + } + return $this->persist_code; + } + }