diff --git a/app/Http/Requests/Vendor/StoreVendorRequest.php b/app/Http/Requests/Vendor/StoreVendorRequest.php index 3ce8ba472198..f60c7997b7cd 100644 --- a/app/Http/Requests/Vendor/StoreVendorRequest.php +++ b/app/Http/Requests/Vendor/StoreVendorRequest.php @@ -38,8 +38,21 @@ class StoreVendorRequest extends Request $user = auth()->user(); $rules = []; - + + $rules['contacts'] = 'bail|array'; $rules['contacts.*.email'] = 'bail|nullable|distinct|sometimes|email'; + $rules['contacts.*.password'] = [ + 'bail', + 'nullable', + 'sometimes', + 'string', + 'min:7', // must be at least 10 characters in length + 'regex:/[a-z]/', // must contain at least one lowercase letter + 'regex:/[A-Z]/', // must contain at least one uppercase letter + 'regex:/[0-9]/', // must contain at least one digit + //'regex:/[@$!%*#?&.]/', // must contain a special character + ]; + if (isset($this->number)) { $rules['number'] = Rule::unique('vendors')->where('company_id', $user->company()->id); diff --git a/app/Http/Requests/Vendor/UpdateVendorRequest.php b/app/Http/Requests/Vendor/UpdateVendorRequest.php index b50e8cf79229..e8b6811fd135 100644 --- a/app/Http/Requests/Vendor/UpdateVendorRequest.php +++ b/app/Http/Requests/Vendor/UpdateVendorRequest.php @@ -45,7 +45,20 @@ class UpdateVendorRequest extends Request $rules['number'] = Rule::unique('vendors')->where('company_id', $user->company()->id)->ignore($this->vendor->id); } - $rules['contacts.*.email'] = 'nullable|distinct'; + $rules['contacts'] = 'bail|array'; + $rules['contacts.*.email'] = 'bail|nullable|distinct|sometimes|email'; + $rules['contacts.*.password'] = [ + 'bail', + 'nullable', + 'sometimes', + 'string', + 'min:7', // must be at least 10 characters in length + 'regex:/[a-z]/', // must contain at least one lowercase letter + 'regex:/[A-Z]/', // must contain at least one uppercase letter + 'regex:/[0-9]/', // must contain at least one digit + //'regex:/[@$!%*#?&.]/', // must contain a special character + ]; + $rules['currency_id'] = 'bail|sometimes|exists:currencies,id'; if ($this->file('documents') && is_array($this->file('documents'))) { diff --git a/app/Repositories/VendorContactRepository.php b/app/Repositories/VendorContactRepository.php index 6827b57d23d8..b2b1647fcfce 100644 --- a/app/Repositories/VendorContactRepository.php +++ b/app/Repositories/VendorContactRepository.php @@ -61,13 +61,23 @@ class VendorContactRepository extends BaseRepository $update_contact->contact_key = Str::random(40); } + if (array_key_exists('email', $contact) && is_null($contact['email'])) { + $contact['email'] = ''; + } + $update_contact->fill($contact); if (array_key_exists('password', $contact) && strlen($contact['password']) > 1) { $update_contact->password = Hash::make($contact['password']); + $vendor->company->vendor_contacts()->where('email', $update_contact->email)->update(['password' => $update_contact->password]); + } + + if (array_key_exists('email', $contact)) { + $update_contact->email = trim($contact['email']); } $update_contact->saveQuietly(); + }); $vendor->load('contacts'); diff --git a/app/Services/Pdf/PdfBuilder.php b/app/Services/Pdf/PdfBuilder.php index 0c844fcba6f1..7a496e17578b 100644 --- a/app/Services/Pdf/PdfBuilder.php +++ b/app/Services/Pdf/PdfBuilder.php @@ -927,7 +927,7 @@ class PdfBuilder */ private function getProductEntityDetails(): self { - if ($this->service->config->entity_string == 'invoice') { + if (in_array($this->service->config->entity_string, ['recurring_invoice', 'invoice'])) { $this->mergeSections([ 'entity-details' => [ 'id' => 'entity-details', diff --git a/app/Transformers/VendorContactTransformer.php b/app/Transformers/VendorContactTransformer.php index ca344634ce5b..7a584e18ca6a 100644 --- a/app/Transformers/VendorContactTransformer.php +++ b/app/Transformers/VendorContactTransformer.php @@ -45,6 +45,7 @@ class VendorContactTransformer extends EntityTransformer 'custom_value4' => $vendor->custom_value4 ?: '', 'link' => $vendor->getLoginLink(), 'last_login' => (int)$vendor->last_login, + 'password' => empty($vendor->password) ? '' : '**********', ]; } } diff --git a/tests/_bootstrap.php b/tests/_bootstrap.php index 1f6877ca56ee..a631610f5897 100644 --- a/tests/_bootstrap.php +++ b/tests/_bootstrap.php @@ -3,7 +3,7 @@ // This is global bootstrap for autoloading use Codeception\Util\Fixtures; -Fixtures::add('url', 'http://www.ninja.test'); +Fixtures::add('url', 'http://localhost'); Fixtures::add('username', 'user@example.com'); Fixtures::add('password', 'password');