Minor fixes for quote permissions

This commit is contained in:
David Bomba 2022-02-17 23:07:16 +11:00
parent 697b379889
commit 6ec6ae8756
4 changed files with 6 additions and 4 deletions

View File

@ -15,7 +15,8 @@ class ShowCreditRequest extends FormRequest
public function authorize() public function authorize()
{ {
return !$this->credit->is_deleted return !$this->credit->is_deleted
&& auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_CREDITS; && auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_CREDITS
&& auth()->guard('contact')->user()->client_id === $this->credit->client_id;
} }
/** /**

View File

@ -27,9 +27,10 @@ class ShowDocumentRequest extends FormRequest
*/ */
public function authorize() public function authorize()
{ {
return auth()->guard('contact')->user()->client_id == $this->document->documentable_id return auth()->guard('contact')->user()->client_id == $this->document->documentable_id
|| $this->document->documentable->client_id == auth()->guard('contact')->user()->client_id
|| $this->document->company_id == auth()->guard('contact')->user()->company_id; || $this->document->company_id == auth()->guard('contact')->user()->company_id;
} }
/** /**

View File

@ -23,7 +23,7 @@ class ShowInvoiceRequest extends Request
*/ */
public function authorize() : bool public function authorize() : bool
{ {
return auth()->guard('contact')->user()->client_id == $this->invoice->client_id return auth()->guard('contact')->user()->client_id === $this->invoice->client_id
&& auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES; && auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES;
} }
} }

View File

@ -19,7 +19,7 @@ class ShowQuoteRequest extends FormRequest
{ {
public function authorize() public function authorize()
{ {
return auth()->user()->client->id === $this->quote->client_id return auth()->guard('contact')->user()->client->id === $this->quote->client_id
&& auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_QUOTES; && auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_QUOTES;
} }