diff --git a/VERSION.txt b/VERSION.txt index 40dc92612c46..16cf70e74867 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.1.15 \ No newline at end of file +5.1.16 \ No newline at end of file diff --git a/app/Factory/CompanyFactory.php b/app/Factory/CompanyFactory.php index 9b9843ea7949..6eb846084dc7 100644 --- a/app/Factory/CompanyFactory.php +++ b/app/Factory/CompanyFactory.php @@ -35,6 +35,7 @@ class CompanyFactory $company->custom_fields = (object) []; $company->subdomain = ''; $company->enabled_modules = config('ninja.enabled_modules'); //32767;//8191; //4095 + $company->default_password_timeout = 30; return $company; } diff --git a/app/Factory/UserFactory.php b/app/Factory/UserFactory.php index 8a4ca5a03ede..d731df89fbc9 100644 --- a/app/Factory/UserFactory.php +++ b/app/Factory/UserFactory.php @@ -28,7 +28,6 @@ class UserFactory $user->failed_logins = 0; $user->signature = ''; $user->theme_id = 0; - $user->default_password_timeout = 30; return $user; } diff --git a/app/Http/Controllers/TwoFactorController.php b/app/Http/Controllers/TwoFactorController.php index 5c780770c6d0..e1f2d68a046e 100644 --- a/app/Http/Controllers/TwoFactorController.php +++ b/app/Http/Controllers/TwoFactorController.php @@ -38,7 +38,7 @@ class TwoFactorController extends BaseController $data = [ 'secret' => $secret, - 'qrCode' => $qrCode, + 'qrCode' => $qr_code, ]; return response()->json(['data' => $data], 200); diff --git a/app/Http/Middleware/PasswordProtection.php b/app/Http/Middleware/PasswordProtection.php index 3c0275d68b57..5d1ad6581faf 100644 --- a/app/Http/Middleware/PasswordProtection.php +++ b/app/Http/Middleware/PasswordProtection.php @@ -31,22 +31,23 @@ class PasswordProtection */ public function handle($request, Closure $next) { - // {nlog($request->headers->all()); - // nlog($request->all()); $error = [ 'message' => 'Invalid Password', 'errors' => new stdClass, ]; - nlog(Cache::get(auth()->user()->hashed_id.'_logged_in')); - nlog($request->header('X-API-OAUTH-PASSWORD')); + $timeout = auth()->user()->company()->default_password_timeout; + if($timeout == 0) + $timeout = null; + else + $timeout = now()->addMinutes($timeout); if (Cache::get(auth()->user()->hashed_id.'_logged_in')) { Cache::pull(auth()->user()->hashed_id.'_logged_in'); - Cache::add(auth()->user()->hashed_id.'_logged_in', Str::random(64), now()->addMinutes(30)); + Cache::add(auth()->user()->hashed_id.'_logged_in', Str::random(64), $timeout); return $next($request); @@ -68,12 +69,12 @@ class PasswordProtection //If OAuth and user also has a password set - check both if ($existing_user = MultiDB::hasUser($query) && auth()->user()->has_password && Hash::check(auth()->user()->password, $request->header('X-API-PASSWORD'))) { - Cache::add(auth()->user()->hashed_id.'_logged_in', Str::random(64), now()->addMinutes(30)); + Cache::add(auth()->user()->hashed_id.'_logged_in', Str::random(64), $timeout); return $next($request); } elseif($existing_user = MultiDB::hasUser($query) && !auth()->user()->has_password){ - Cache::add(auth()->user()->hashed_id.'_logged_in', Str::random(64), now()->addMinutes(30)); + Cache::add(auth()->user()->hashed_id.'_logged_in', Str::random(64), $timeout); return $next($request); } } @@ -83,7 +84,7 @@ class PasswordProtection }elseif ($request->header('X-API-PASSWORD') && Hash::check($request->header('X-API-PASSWORD'), auth()->user()->password)) { - Cache::add(auth()->user()->hashed_id.'_logged_in', Str::random(64), now()->addMinutes(30)); + Cache::add(auth()->user()->hashed_id.'_logged_in', Str::random(64), $timeout); return $next($request); diff --git a/app/Models/Company.php b/app/Models/Company.php index 8706ff03f8ca..16bc053a5a5a 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -86,6 +86,7 @@ class Company extends BaseModel 'session_timeout', 'oauth_password_required', 'invoice_task_datelog', + 'default_password_timeout', ]; protected $hidden = [ diff --git a/app/Models/User.php b/app/Models/User.php index 993293c83976..f9fb94e5b59f 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -82,7 +82,6 @@ class User extends Authenticatable implements MustVerifyEmail 'custom_value4', 'is_deleted', 'google_2fa_secret', - 'default_password_timeout', ]; /** diff --git a/app/Transformers/CompanyTransformer.php b/app/Transformers/CompanyTransformer.php index 3f9b34104fb7..308cf6cde8b7 100644 --- a/app/Transformers/CompanyTransformer.php +++ b/app/Transformers/CompanyTransformer.php @@ -154,6 +154,7 @@ class CompanyTransformer extends EntityTransformer 'expense_amount_is_pretax' =>(bool)true, //@deprecate 1-2-2021 'oauth_password_required' => (bool)$company->oauth_password_required, 'session_timeout' => (int)$company->session_timeout, + 'default_password_timeout' => (int) $company->default_password_timeout, ]; } diff --git a/config/ninja.php b/config/ninja.php index f9c64b250f51..481fea721939 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -13,7 +13,7 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', ''), - 'app_version' => '5.1.15', + 'app_version' => '5.1.16', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', false), diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 2ae42bc187ca..2f79366abee3 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -37,7 +37,6 @@ class UserFactory extends Factory 'email_verified_at' => now(), 'password' => bcrypt(config('ninja.testvars.password')), // secret 'remember_token' => \Illuminate\Support\Str::random(10), - 'default_password_timeout' => 30, ]; } } diff --git a/database/migrations/2021_03_08_205030_add_russian_lang.php b/database/migrations/2021_03_08_205030_add_russian_lang.php index 500e857fb020..443de5c73660 100644 --- a/database/migrations/2021_03_08_205030_add_russian_lang.php +++ b/database/migrations/2021_03_08_205030_add_russian_lang.php @@ -1,5 +1,6 @@ integer('default_password_timeout')->default(30); }); - User::whereNotNull('id')->update(['default_password_timeout' => 30]); + Company::whereNotNull('id')->update(['default_password_timeout' => 30]); } diff --git a/resources/views/email/import/completed.blade.php b/resources/views/email/import/completed.blade.php index 430ab9120dd2..951de9ea7674 100644 --- a/resources/views/email/import/completed.blade.php +++ b/resources/views/email/import/completed.blade.php @@ -11,73 +11,70 @@
Clients Imported: {{ $company->clients->count() }}
+{{ ctrans('texts.clients') }}: {{ $company->clients->count() }}
@endif @if(isset($company) && count($company->products) >=1) -Products Imported: {{ count($company->products) }}
+{{ ctrans('texts.products') }}: {{ count($company->products) }}
@endif @if(isset($company) && count($company->invoices) >=1) -Invoices Imported: {{ count($company->invoices) }}
- -To test your PDF generation is working correctly, click here. We've also attempted to attach the PDF to this email. - +
{{ ctrans('texts.invoices') }}: {{ count($company->invoices) }}
@endif @if(isset($company) && count($company->payments) >=1) -Payments Imported: {{ count($company->payments) }}
+{{ ctrans('texts.payments') }}: {{ count($company->payments) }}
@endif @if(isset($company) && count($company->recurring_invoices) >=1) -Recurring Invoices Imported: {{ count($company->recurring_invoices) }}
+{{ ctrans('texts.recurring_invoices') }}: {{ count($company->recurring_invoices) }}
@endif @if(isset($company) && count($company->quotes) >=1) -Quotes Imported: {{ count($company->quotes) }}
+{{ ctrans('texts.quotes') }}: {{ count($company->quotes) }}
@endif @if(isset($company) && count($company->credits) >=1) -Credits Imported: {{ count($company->credits) }}
+{{ ctrans('texts.credits') }}: {{ count($company->credits) }}
@endif @if(isset($company) && count($company->projects) >=1) -Projects Imported: {{ count($company->projects) }}
+{{ ctrans('texts.projects') }}: {{ count($company->projects) }}
@endif @if(isset($company) && count($company->tasks) >=1) -Tasks Imported: {{ count($company->tasks) }}
+{{ ctrans('texts.tasks') }}: {{ count($company->tasks) }}
@endif @if(isset($company) && count($company->vendors) >=1) -Vendors Imported: {{ count($company->vendors) }}
+{{ ctrans('texts.vendors') }}: {{ count($company->vendors) }}
@endif @if(isset($company) && count($company->expenses) >=1) -Expenses Imported: {{ count($company->expenses) }}
+{{ ctrans('texts.expenses') }}: {{ count($company->expenses) }}
@endif @if(isset($company) && count($company->company_gateways) >=1) -Gateways Imported: {{ count($company->company_gateways) }}
+{{ ctrans('texts.gateways') }}: {{ count($company->company_gateways) }}
@endif @if(isset($company) && count($company->client_gateway_tokens) >=1) -Client Gateway Tokens Imported: {{ count($company->client_gateway_tokens) }}
+{{ ctrans('texts.tokens') }}: {{ count($company->client_gateway_tokens) }}
@endif @if(isset($company) && count($company->tax_rates) >=1) -Tax Rates Imported: {{ count($company->tax_rates) }}
+{{ ctrans('texts.tax_rates') }}: {{ count($company->tax_rates) }}
@endif @if(isset($company) && count($company->documents) >=1) -Documents Imported: {{ count($company->documents) }}
+{{ ctrans('texts.documents') }}: {{ count($company->documents) }}
@endifData Quality:
{!! $check_data !!}
@if(!empty($errors) ) -The following import errors occurred:
+{{ ctrans('texts.errors') }}: