diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index bc1b6f1cf5..3ce1032ce9 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -12,7 +12,7 @@ jobs: runs-on: ${{ matrix.operating-system }} strategy: matrix: - operating-system: ['ubuntu-18.04', 'ubuntu-20.04', 'ubuntu-22.04'] + operating-system: ['ubuntu-18.04', 'ubuntu-20.04'] php-versions: ['7.4','8.0','8.1'] phpunit-versions: ['latest'] diff --git a/app/Http/Requests/Account/CreateAccountRequest.php b/app/Http/Requests/Account/CreateAccountRequest.php index 363ec222b6..78661967c3 100644 --- a/app/Http/Requests/Account/CreateAccountRequest.php +++ b/app/Http/Requests/Account/CreateAccountRequest.php @@ -12,7 +12,10 @@ namespace App\Http\Requests\Account; use App\Http\Requests\Request; +use App\Http\ValidationRules\Account\BlackListRule; +use App\Http\ValidationRules\Account\EmailBlackListRule; use App\Http\ValidationRules\NewUniqueUserRule; +use App\Utils\Ninja; class CreateAccountRequest extends Request { @@ -33,13 +36,18 @@ class CreateAccountRequest extends Request */ public function rules() { + + if(Ninja::isHosted()) + $email_rules = ['required', 'email:rfc,dns', new NewUniqueUserRule, new BlackListRule, new EmailBlackListRule]; + else + $email_rules = ['required', 'email:rfc,dns', new NewUniqueUserRule]; + + return [ 'first_name' => 'string|max:100', 'last_name' => 'string:max:100', 'password' => 'required|string|min:6|max:1000', - // 'email' => 'bail|required|email:rfc,dns', - // 'email' => new NewUniqueUserRule(), - 'email' => ['required', 'email:rfc,dns', new NewUniqueUserRule], + 'email' => $email_rules, 'privacy_policy' => 'required|boolean', 'terms_of_service' => 'required|boolean', ]; diff --git a/app/Http/Requests/Login/LoginRequest.php b/app/Http/Requests/Login/LoginRequest.php index 2f8b42e0c3..01c67c281e 100644 --- a/app/Http/Requests/Login/LoginRequest.php +++ b/app/Http/Requests/Login/LoginRequest.php @@ -14,6 +14,7 @@ namespace App\Http\Requests\Login; use App\Http\Requests\Request; use App\Http\ValidationRules\Account\BlackListRule; +use App\Http\ValidationRules\Account\EmailBlackListRule; use App\Utils\Ninja; class LoginRequest extends Request @@ -38,7 +39,7 @@ class LoginRequest extends Request { if(Ninja::isHosted()) - $email_rules = ['required', new BlackListRule]; + $email_rules = ['required', new BlackListRule, new EmailBlackListRule]; else $email_rules = 'required'; diff --git a/app/Http/ValidationRules/Account/EmailBlackListRule.php b/app/Http/ValidationRules/Account/EmailBlackListRule.php new file mode 100644 index 0000000000..06a5f854a9 --- /dev/null +++ b/app/Http/ValidationRules/Account/EmailBlackListRule.php @@ -0,0 +1,47 @@ +blacklist); + + } + + /** + * @return string + */ + public function message() + { + return "This email address is blacklisted, if you think this is in error, please email contact@invoiceninja.com"; + } + + +} diff --git a/app/Jobs/Account/CreateAccount.php b/app/Jobs/Account/CreateAccount.php index e74b56aa5f..59560b8033 100644 --- a/app/Jobs/Account/CreateAccount.php +++ b/app/Jobs/Account/CreateAccount.php @@ -156,45 +156,6 @@ class CreateAccount return $sp794f3f; } - // private function processSettings($settings) - // { - // if(Ninja::isHosted() && Cache::get('currencies')) - // { - - // $currency = Cache::get('currencies')->filter(function ($item) use ($currency_code) { - // return strtolower($item->code) == $currency_code; - // })->first(); - - // if ($currency) { - // $settings->currency_id = (string)$currency->id; - // } - - // $country = Cache::get('countries')->filter(function ($item) use ($country_code) { - // return strtolower($item->iso_3166_2) == $country_code || strtolower($item->iso_3166_3) == $country_code; - // })->first(); - - // if ($country) { - // $settings->country_id = (string)$country->id; - // } - - // $language = Cache::get('languages')->filter(function ($item) use ($currency_code) { - // return strtolower($item->locale) == $currency_code; - // })->first(); - - // if ($language) { - // $settings->language_id = (string)$language->id; - // } - - // if($timezone) { - // $settings->timezone_id = (string)$timezone->id; - // } - - // return $settings; - // } - - - // return $settings; - // } } diff --git a/app/Jobs/Util/StartMigration.php b/app/Jobs/Util/StartMigration.php index 94716c210a..0368b37d98 100644 --- a/app/Jobs/Util/StartMigration.php +++ b/app/Jobs/Util/StartMigration.php @@ -132,7 +132,6 @@ class StartMigration implements ShouldQueue $this->company->update_products = $update_product_flag; $this->company->save(); - if(Ninja::isHosted()) app('sentry')->captureException($e); diff --git a/database/migrations/2022_04_26_032252_convert_custom_fields_column_from_varchar_to_text.php b/database/migrations/2022_04_26_032252_convert_custom_fields_column_from_varchar_to_text.php index 520730dca1..47d4da044a 100644 --- a/database/migrations/2022_04_26_032252_convert_custom_fields_column_from_varchar_to_text.php +++ b/database/migrations/2022_04_26_032252_convert_custom_fields_column_from_varchar_to_text.php @@ -1,5 +1,6 @@ text('custom_value1')->change(); $table->text('custom_value2')->change(); $table->text('custom_value3')->change(); - $table->text('custom_value3')->change(); + $table->text('custom_value4')->change(); }); @@ -29,7 +30,7 @@ class ConvertCustomFieldsColumnFromVarcharToText extends Migration $table->text('custom_value1')->change(); $table->text('custom_value2')->change(); $table->text('custom_value3')->change(); - $table->text('custom_value3')->change(); + $table->text('custom_value4')->change(); }); @@ -38,16 +39,7 @@ class ConvertCustomFieldsColumnFromVarcharToText extends Migration $table->text('custom_value1')->change(); $table->text('custom_value2')->change(); $table->text('custom_value3')->change(); - $table->text('custom_value3')->change(); - - }); - - Schema::table('clients', function (Blueprint $table) { - - $table->text('custom_value1')->change(); - $table->text('custom_value2')->change(); - $table->text('custom_value3')->change(); - $table->text('custom_value3')->change(); + $table->text('custom_value4')->change(); }); @@ -56,7 +48,7 @@ class ConvertCustomFieldsColumnFromVarcharToText extends Migration $table->text('custom_value1')->change(); $table->text('custom_value2')->change(); $table->text('custom_value3')->change(); - $table->text('custom_value3')->change(); + $table->text('custom_value4')->change(); }); @@ -65,7 +57,7 @@ class ConvertCustomFieldsColumnFromVarcharToText extends Migration $table->text('custom_value1')->change(); $table->text('custom_value2')->change(); $table->text('custom_value3')->change(); - $table->text('custom_value3')->change(); + $table->text('custom_value4')->change(); }); @@ -74,7 +66,7 @@ class ConvertCustomFieldsColumnFromVarcharToText extends Migration $table->text('custom_value1')->change(); $table->text('custom_value2')->change(); $table->text('custom_value3')->change(); - $table->text('custom_value3')->change(); + $table->text('custom_value4')->change(); }); @@ -83,7 +75,7 @@ class ConvertCustomFieldsColumnFromVarcharToText extends Migration $table->text('custom_value1')->change(); $table->text('custom_value2')->change(); $table->text('custom_value3')->change(); - $table->text('custom_value3')->change(); + $table->text('custom_value4')->change(); }); @@ -92,7 +84,7 @@ class ConvertCustomFieldsColumnFromVarcharToText extends Migration $table->text('custom_value1')->change(); $table->text('custom_value2')->change(); $table->text('custom_value3')->change(); - $table->text('custom_value3')->change(); + $table->text('custom_value4')->change(); }); @@ -101,7 +93,7 @@ class ConvertCustomFieldsColumnFromVarcharToText extends Migration $table->text('custom_value1')->change(); $table->text('custom_value2')->change(); $table->text('custom_value3')->change(); - $table->text('custom_value3')->change(); + $table->text('custom_value4')->change(); }); @@ -110,7 +102,7 @@ class ConvertCustomFieldsColumnFromVarcharToText extends Migration $table->text('custom_value1')->change(); $table->text('custom_value2')->change(); $table->text('custom_value3')->change(); - $table->text('custom_value3')->change(); + $table->text('custom_value4')->change(); }); @@ -119,7 +111,7 @@ class ConvertCustomFieldsColumnFromVarcharToText extends Migration $table->text('custom_value1')->change(); $table->text('custom_value2')->change(); $table->text('custom_value3')->change(); - $table->text('custom_value3')->change(); + $table->text('custom_value4')->change(); }); @@ -128,7 +120,7 @@ class ConvertCustomFieldsColumnFromVarcharToText extends Migration $table->text('custom_value1')->change(); $table->text('custom_value2')->change(); $table->text('custom_value3')->change(); - $table->text('custom_value3')->change(); + $table->text('custom_value4')->change(); }); @@ -137,7 +129,7 @@ class ConvertCustomFieldsColumnFromVarcharToText extends Migration $table->text('custom_value1')->change(); $table->text('custom_value2')->change(); $table->text('custom_value3')->change(); - $table->text('custom_value3')->change(); + $table->text('custom_value4')->change(); }); @@ -146,7 +138,7 @@ class ConvertCustomFieldsColumnFromVarcharToText extends Migration $table->text('custom_value1')->change(); $table->text('custom_value2')->change(); $table->text('custom_value3')->change(); - $table->text('custom_value3')->change(); + $table->text('custom_value4')->change(); }); @@ -155,7 +147,7 @@ class ConvertCustomFieldsColumnFromVarcharToText extends Migration $table->text('custom_value1')->change(); $table->text('custom_value2')->change(); $table->text('custom_value3')->change(); - $table->text('custom_value3')->change(); + $table->text('custom_value4')->change(); }); @@ -164,7 +156,7 @@ class ConvertCustomFieldsColumnFromVarcharToText extends Migration $table->text('custom_value1')->change(); $table->text('custom_value2')->change(); $table->text('custom_value3')->change(); - $table->text('custom_value3')->change(); + $table->text('custom_value4')->change(); }); @@ -173,10 +165,10 @@ class ConvertCustomFieldsColumnFromVarcharToText extends Migration $table->text('custom_value1')->change(); $table->text('custom_value2')->change(); $table->text('custom_value3')->change(); - $table->text('custom_value3')->change(); + $table->text('custom_value4')->change(); }); - + } /** diff --git a/tests/Unit/ValidationRules/EmailBlacklistValidationTest.php b/tests/Unit/ValidationRules/EmailBlacklistValidationTest.php new file mode 100644 index 0000000000..2852728374 --- /dev/null +++ b/tests/Unit/ValidationRules/EmailBlacklistValidationTest.php @@ -0,0 +1,70 @@ +blacklist = ['gimmy@gmail.com']; + + $rules = [ + 'email' => [$email_rule] + ]; + + $data = [ + 'email' => "gimmy@gmail.com", + ]; + + $v = $this->app['validator']->make($data, $rules); + $this->assertFalse($v->passes()); + } + + + public function testInValidEmailRule() + { + + $rules = [ + 'email' => [new EmailBlackListRule] + ]; + + $data = [ + 'email' => "jimmy@candassociates.com", + ]; + + $v = $this->app['validator']->make($data, $rules); + $this->assertTrue($v->passes()); + } + + + + +}