Auth global

This commit is contained in:
2020-02-18 12:14:16 -03:00
parent aa72f8018d
commit c7084415f0

View File

@ -32,11 +32,16 @@ class Auth extends Model
} }
public function time($time = null) public function time($time = null)
{ {
if ($this->container === null) {
$timezone = config('app.timezone');
} else {
$timezone = $this->container->get('settings')->app->timezone;
}
if ($time == null) { if ($time == null) {
return Carbon::parse($this->time, $this->container->get('settings')->app->timezone); return Carbon::parse($this->time, $timezone);
} }
if (!\is_a($time, \DateTime::class)) { if (!\is_a($time, \DateTime::class)) {
$time = Carbon::parse($time, $this->container->get('settings')->app->timezone); $time = Carbon::parse($time, $timezone);
} }
$this->time = $time; $this->time = $time;
} }
@ -52,9 +57,19 @@ class Auth extends Model
if ($this->status == 0) { if ($this->status == 0) {
return false; return false;
} }
$now = Carbon::now($this->container->get('settings')->app->timezone); if ($this->container === null) {
$timezone = config('app.timezone');
} else {
$timezone = $this->container->get('settings')->app->timezone;
}
$now = Carbon::now($timezone);
$diff = $now->diffAsCarbonInterval($this->time, true); $diff = $now->diffAsCarbonInterval($this->time, true);
if ($diff->totalHours > $this->container->get('settings')->app->login->hours) { if ($this->container === null) {
$total_hours = config('app.login.hours');
} else {
$total_hours = $this->container->get('settings')->app->login->hours;
}
if ($diff->totalHours > $total_hours) {
return false; return false;
} }
return true; return true;