koel/app/Policies/UserPolicy.php
Pedro Borges 899c7176c1 Use Laravel built-in authorization
The comment below motivated me to find a better solution for the
repeated authorisation checks:

```php
// This can't be put into a Request authorize(), due to Laravel(?)'s
limitation.
```

This is the result.
2015-12-14 14:27:26 -02:00

16 lines
317 B
PHP

<?php
namespace App\Policies;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
class UserPolicy
{
use HandlesAuthorization;
public function destroy(User $currentUser, User $userToDestroy)
{
return $currentUser->is_admin || $currentUser->id !== $userToDestroy->id;
}
}