mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Revert for scheduler storatge
This commit is contained in:
parent
f58018c8e8
commit
4edb123d42
@ -11,18 +11,13 @@
|
||||
|
||||
namespace App\Http\Requests\TaskScheduler;
|
||||
|
||||
use App\Utils\Ninja;
|
||||
use App\Http\Requests\Request;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Auth\Access\AuthorizationException;
|
||||
use App\Http\ValidationRules\Scheduler\ValidClientIds;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
|
||||
class StoreSchedulerRequest extends Request
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
private string $error_message = '';
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
@ -30,13 +25,10 @@ class StoreSchedulerRequest extends Request
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
// /** @var \App\Models\User $user */
|
||||
// $user = auth()->user();
|
||||
|
||||
// return $user->isAdmin();
|
||||
|
||||
return $this->checkUserAbleToSave();
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
return $user->isAdmin();
|
||||
}
|
||||
|
||||
public function rules()
|
||||
@ -82,39 +74,11 @@ class StoreSchedulerRequest extends Request
|
||||
if(isset($input['parameters']['status'])) {
|
||||
|
||||
$input['parameters']['status'] = collect(explode(",", $input['parameters']['status']))
|
||||
->filter(function($status) {
|
||||
->filter(function ($status) {
|
||||
return in_array($status, ['all','draft','paid','unpaid','overdue']);
|
||||
})->implode(",") ?? '';
|
||||
}
|
||||
|
||||
$this->replace($input);
|
||||
}
|
||||
|
||||
|
||||
private function checkUserAbleToSave()
|
||||
{
|
||||
|
||||
$this->error_message = ctrans('texts.authorization_failure');
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
if(Ninja::isSelfHost() && $user->isAdmin())
|
||||
return true;
|
||||
|
||||
if(Ninja::isHosted() && $user->account->isPaid() && $user->isAdmin()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(Ninja::isHosted() && !$user->account->isPaid())
|
||||
$this->error_message = ctrans('texts.upgrade_to_paid_plan');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function failedAuthorization()
|
||||
{
|
||||
throw new AuthorizationException($this->error_message);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,16 +10,11 @@
|
||||
*/
|
||||
namespace App\Http\Requests\TaskScheduler;
|
||||
|
||||
use App\Utils\Ninja;
|
||||
use App\Http\Requests\Request;
|
||||
use Illuminate\Auth\Access\AuthorizationException;
|
||||
use App\Http\ValidationRules\Scheduler\ValidClientIds;
|
||||
|
||||
class UpdateSchedulerRequest extends Request
|
||||
{
|
||||
|
||||
private string $error_message = '';
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
@ -27,9 +22,10 @@ class UpdateSchedulerRequest extends Request
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
return $this->checkUserAbleToSave();
|
||||
|
||||
return $user->isAdmin() && $this->task_scheduler->company_id == $user->company()->id;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
@ -82,32 +78,7 @@ class UpdateSchedulerRequest extends Request
|
||||
|
||||
$this->replace($input);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function checkUserAbleToSave()
|
||||
{
|
||||
|
||||
$this->error_message = ctrans('texts.authorization_failure');
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
if(Ninja::isSelfHost() && $user->isAdmin() && $this->task_scheduler->company_id == $user->company()->id)
|
||||
return true;
|
||||
|
||||
if(Ninja::isHosted() && $user->account->isPaid() && $user->isAdmin() && $this->task_scheduler->company_id == $user->company()->id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(Ninja::isHosted() && !$user->account->isPaid())
|
||||
$this->error_message = ctrans('texts.upgrade_to_paid_plan');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function failedAuthorization()
|
||||
{
|
||||
throw new AuthorizationException($this->error_message);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user