mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
* Update Laravel core files Fix app/Http/Kernel.php * Use RouteServiceProvider::HOME * Sync Laravel default config files * Update composer dependencies to Laravel 6 * fix resources/lang/en/validation.php * Manually fixing tests required by travis, fails locally??? * Update wpb/string-blade-compiler * Add new viewany() authorization policies * Update minimum PHP version to 7.2 * Re-generate our json test-dumps Due to: https://github.com/laravel/framework/pull/16069 https://github.com/laravel/framework/pull/31100 * update truenas data * fix truenas Co-authored-by: Laravel Shift <shift@laravelshift.com> Co-authored-by: Tony Murray <murraytony@gmail.com>
82 lines
1.6 KiB
PHP
82 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Policies;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Auth\Access\HandlesAuthorization;
|
|
|
|
class UserPolicy
|
|
{
|
|
use HandlesAuthorization;
|
|
|
|
/**
|
|
* Determine whether the user can manage users.
|
|
*
|
|
* @param \App\Models\User $user
|
|
* @return bool
|
|
*/
|
|
public function manage(User $user)
|
|
{
|
|
return $user->isAdmin();
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can view the user.
|
|
*
|
|
* @param \App\Models\User $user
|
|
* @param \App\Models\User $target
|
|
* @return bool
|
|
*/
|
|
public function view(User $user, User $target)
|
|
{
|
|
return $user->isAdmin() || $target->is($user);
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can view any user.
|
|
*
|
|
* @param \App\User $user
|
|
* @return mixed
|
|
*/
|
|
public function viewAny(User $user)
|
|
{
|
|
return $user->isAdmin();
|
|
}
|
|
|
|
|
|
/**
|
|
* Determine whether the user can create users.
|
|
*
|
|
* @param \App\Models\User $user
|
|
* @return bool
|
|
*/
|
|
public function create(User $user)
|
|
{
|
|
return $user->isAdmin();
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can update the user.
|
|
*
|
|
* @param \App\Models\User $user
|
|
* @param \App\Models\User $target
|
|
* @return bool
|
|
*/
|
|
public function update(User $user, User $target)
|
|
{
|
|
return $user->isAdmin() || $target->is($user);
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can delete the user.
|
|
*
|
|
* @param \App\Models\User $user
|
|
* @param \App\Models\User $target
|
|
* @return bool
|
|
*/
|
|
public function delete(User $user, User $target)
|
|
{
|
|
return $user->isAdmin();
|
|
}
|
|
}
|