1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 12:12:48 +01:00

Fix for archiving API token

This commit is contained in:
Hillel Coren 2016-08-02 17:38:51 +03:00
parent 16aadf5615
commit 8dc1786eb2
4 changed files with 8 additions and 6 deletions

View File

@ -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;
}

View File

@ -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');
}
}
}

View File

@ -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,
];

View File

@ -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);
}
}