Fixes #903 - adds config variable for multi_login, overrides Sentry method

This commit is contained in:
snipe
2015-07-09 00:41:46 -07:00
parent c2d63915c3
commit f8be47dfbf
5 changed files with 480 additions and 12 deletions
+31 -12
View File
@@ -23,7 +23,7 @@ class User extends SentryUserModel
{
return "{$this->first_name} {$this->last_name}";
}
/**
* Returns the user Gravatar image url.
@@ -43,7 +43,7 @@ class User extends SentryUserModel
{
return $this->hasMany('Asset', 'assigned_to')->withTrashed();
}
public function accessories()
{
return $this->belongsToMany('Accessory', 'accessories_users', 'assigned_to','accessory_id')->withPivot('id')->withTrashed();
@@ -77,36 +77,55 @@ class User extends SentryUserModel
{
return $this->belongsTo('User','manager_id')->withTrashed();
}
public function accountStatus()
{
if ($this->sentryThrottle) {
if ($this->sentryThrottle->suspended==1) {
return 'suspended';
return 'suspended';
} elseif ($this->sentryThrottle->banned==1) {
return 'banned';
} else {
return 'banned';
} else {
return false;
}
} else {
return false;
}
}
public function sentryThrottle() {
return $this->hasOne('Throttle');
public function sentryThrottle() {
return $this->hasOne('Throttle');
}
public function scopeGetDeleted($query)
{
return $query->withTrashed()->whereNotNull('deleted_at');
}
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('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;
}
}