diff --git a/VERSION.txt b/VERSION.txt index 8cd1f2d6abb9..d6701612336e 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.2.17 \ No newline at end of file +5.2.18 \ No newline at end of file diff --git a/app/Http/Requests/Client/StoreClientRequest.php b/app/Http/Requests/Client/StoreClientRequest.php index a27df9afb5d6..dbf51b660336 100644 --- a/app/Http/Requests/Client/StoreClientRequest.php +++ b/app/Http/Requests/Client/StoreClientRequest.php @@ -54,6 +54,7 @@ class StoreClientRequest extends Request /* Ensure we have a client name, and that all emails are unique*/ //$rules['name'] = 'required|min:1'; $rules['settings'] = new ValidClientGroupSettingsRule(); + $rules['contacts'] = 'array'; $rules['contacts.*.email'] = 'bail|nullable|distinct|sometimes|email'; $rules['contacts.*.password'] = [ 'nullable', diff --git a/app/Http/Requests/Client/UpdateClientRequest.php b/app/Http/Requests/Client/UpdateClientRequest.php index d160f20aa241..dd179d1d86e0 100644 --- a/app/Http/Requests/Client/UpdateClientRequest.php +++ b/app/Http/Requests/Client/UpdateClientRequest.php @@ -62,6 +62,7 @@ class UpdateClientRequest extends Request $rules['number'] = Rule::unique('clients')->where('company_id', auth()->user()->company()->id)->ignore($this->client->id); $rules['settings'] = new ValidClientGroupSettingsRule(); + $rules['contacts'] = 'array'; $rules['contacts.*.email'] = 'bail|nullable|distinct|sometimes|email'; $rules['contacts.*.password'] = [ 'nullable', diff --git a/config/ninja.php b/config/ninja.php index df8f43af1882..eb3f54f5b066 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -14,8 +14,8 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'), - 'app_version' => '5.2.17', - 'app_tag' => '5.2.17', + 'app_version' => '5.2.18', + 'app_tag' => '5.2.18', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''), diff --git a/resources/views/index/index.blade.php b/resources/views/index/index.blade.php index fcaf04fb8eaa..234deb431cac 100644 --- a/resources/views/index/index.blade.php +++ b/resources/views/index/index.blade.php @@ -3,7 +3,7 @@ - + diff --git a/tests/Feature/ClientTest.php b/tests/Feature/ClientTest.php index 92253807588e..f39bf0f9f037 100644 --- a/tests/Feature/ClientTest.php +++ b/tests/Feature/ClientTest.php @@ -263,6 +263,63 @@ class ClientTest extends TestCase $this->assertEquals($this->client->contacts->count(), 3); } + public function testClientCreationWithIllegalContactObject() + { + + $account = Account::factory()->create(); + $company = Company::factory()->create([ + 'account_id' => $account->id, + ]); + + $account->default_company_id = $company->id; + $account->save(); + + $user = User::factory()->create([ + 'account_id' => $account->id, + 'confirmation_code' => $this->createDbHash(config('database.default')), + 'email' => 'whiz@gmail.com', + + ]); + + $user->companies()->attach($company->id, [ + 'account_id' => $account->id, + 'is_owner' => 1, + 'is_admin' => 1, + 'notifications' => CompanySettings::notificationDefaults(), + 'permissions' => '', + 'settings' => '', + 'is_locked' => 0, + ]); + + $company_token = new CompanyToken; + $company_token->user_id = $user->id; + $company_token->company_id = $company->id; + $company_token->account_id = $account->id; + $company_token->name = $user->first_name.' '.$user->last_name; + $company_token->token = Str::random(64); + $company_token->save(); + + $this->token = $company_token->token; + + + $data = [ + 'name' => 'A loyal Client', + 'contacts' => $this->faker->unique()->safeEmail, + ]; + + try{ + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->post('/api/v1/clients/', $data); + }catch (ValidationException $e) { + $message = json_decode($e->validator->getMessageBag(), 1); + $this->assertNotNull($message); + } + + + } + public function testCreatingClientAndContacts() { $account = Account::factory()->create();