From 793247e0f7b126f7fb3cf649c712065d8792d7ef Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 22 Mar 2021 21:55:09 +1100 Subject: [PATCH] Fixes for default timeouts --- app/Http/Controllers/Auth/LoginController.php | 4 ++-- app/Http/Controllers/ConnectedAccountController.php | 5 +++++ app/Jobs/Company/CreateCompany.php | 1 + app/Mail/SupportMessageSent.php | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 9258d9e8c6..a9c20f8be7 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -193,9 +193,9 @@ class LoginController extends BaseController } $user->setCompany($user->account->default_company); - $timeout = auth()->user()->company()->default_password_timeout; + // $timeout = auth()->user()->company()->default_password_timeout; - Cache::put(auth()->user()->hashed_id.'_logged_in', Str::random(64), $timeout); + // Cache::put(auth()->user()->hashed_id.'_logged_in', Str::random(64), $timeout); $cu = CompanyUser::query() ->where('user_id', auth()->user()->id); diff --git a/app/Http/Controllers/ConnectedAccountController.php b/app/Http/Controllers/ConnectedAccountController.php index 8464c931be..e6ec51c383 100644 --- a/app/Http/Controllers/ConnectedAccountController.php +++ b/app/Http/Controllers/ConnectedAccountController.php @@ -19,6 +19,7 @@ use App\Transformers\CompanyUserTransformer; use App\Transformers\UserTransformer; use Google_Client; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Cache; class ConnectedAccountController extends BaseController { @@ -111,6 +112,10 @@ class ConnectedAccountController extends BaseController auth()->user()->email_verified_at = now(); auth()->user()->save(); + $timeout = auth()->user()->company()->default_password_timeout; + Cache::put(auth()->user()->hashed_id.'_logged_in', Str::random(64), $timeout); + + return $this->itemResponse(auth()->user()); } diff --git a/app/Jobs/Company/CreateCompany.php b/app/Jobs/Company/CreateCompany.php index bc19b9a9f7..80abe9b569 100644 --- a/app/Jobs/Company/CreateCompany.php +++ b/app/Jobs/Company/CreateCompany.php @@ -59,6 +59,7 @@ class CreateCompany $company->enabled_modules = config('ninja.enabled_modules'); $company->subdomain = isset($this->request['subdomain']) ? $this->request['subdomain'] : ''; $company->custom_fields = new \stdClass; + $company->default_password_timeout = 1800000; $company->save(); return $company; diff --git a/app/Mail/SupportMessageSent.php b/app/Mail/SupportMessageSent.php index 2dd7d51bea..64877f12a6 100644 --- a/app/Mail/SupportMessageSent.php +++ b/app/Mail/SupportMessageSent.php @@ -45,7 +45,7 @@ class SupportMessageSent extends Mailable $log_file->seek(PHP_INT_MAX); $last_line = $log_file->key(); - $lines = new LimitIterator($log_file, $last_line - 10, $last_line); + $lines = new LimitIterator($log_file, $last_line - 100, $last_line); $log_lines = iterator_to_array($lines); }