From 8dc1786eb25a86fc347df3cca00a4c3815140181 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 2 Aug 2016 17:38:51 +0300 Subject: [PATCH] Fix for archiving API token --- app/Policies/EntityPolicy.php | 2 +- app/Policies/TokenPolicy.php | 8 +++++--- app/Providers/AuthServiceProvider.php | 2 +- app/Services/BaseService.php | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/Policies/EntityPolicy.php b/app/Policies/EntityPolicy.php index 3eca53333f..04951f35e2 100644 --- a/app/Policies/EntityPolicy.php +++ b/app/Policies/EntityPolicy.php @@ -45,7 +45,7 @@ class EntityPolicy * @param $ownerUserId * @return bool */ - public static function viewByOwner(User$user, $ownerUserId) { + public static function viewByOwner(User $user, $ownerUserId) { return $user->hasPermission('view_all') || $user->id == $ownerUserId; } diff --git a/app/Policies/TokenPolicy.php b/app/Policies/TokenPolicy.php index 36e37e313a..fff0ffc1f6 100644 --- a/app/Policies/TokenPolicy.php +++ b/app/Policies/TokenPolicy.php @@ -2,12 +2,14 @@ namespace App\Policies; +use App\Models\User; + class TokenPolicy extends EntityPolicy { - public static function edit($user, $item) { + public static function edit(User $user, $item) { return $user->hasPermission('admin'); } - public static function create($user) { + public static function create(User $user) { return $user->hasPermission('admin'); } -} \ No newline at end of file +} diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index bd826f6405..b395cca2c6 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -25,7 +25,7 @@ class AuthServiceProvider extends ServiceProvider \App\Models\Product::class => \App\Policies\ProductPolicy::class, \App\Models\TaxRate::class => \App\Policies\TaxRatePolicy::class, \App\Models\AccountGateway::class => \App\Policies\AccountGatewayPolicy::class, - \App\Models\Token::class => \App\Policies\TokenPolicy::class, + \App\Models\AccountToken::class => \App\Policies\TokenPolicy::class, \App\Models\BankAccount::class => \App\Policies\BankAccountPolicy::class, \App\Models\PaymentTerm::class => \App\Policies\PaymentTermPolicy::class, ]; diff --git a/app/Services/BaseService.php b/app/Services/BaseService.php index 5eda427119..5bc2314518 100644 --- a/app/Services/BaseService.php +++ b/app/Services/BaseService.php @@ -32,7 +32,7 @@ class BaseService $entities = $this->getRepo()->findByPublicIdsWithTrashed($ids); foreach ($entities as $entity) { - if(Auth::user()->can('edit', $entity)){ + if (Auth::user()->can('edit', $entity)) { $this->getRepo()->$action($entity); } }