mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 06:24:44 +02:00

* allow to assign nodes to roles * fix typo * fix node policy * small ui improvements * add missing translation * make phpstan happy * fix migration on mysql * also restrict mounts & database hosts to allowed nodes * fix migration on mysql v2 * changes from review * fix hasManyThrough * change `accessibleNodes` to builder Co-authored-by: RMartinOscar <40749467+RMartinOscar@users.noreply.github.com> --------- Co-authored-by: RMartinOscar <40749467+RMartinOscar@users.noreply.github.com>
28 lines
484 B
PHP
28 lines
484 B
PHP
<?php
|
|
|
|
namespace App\Policies;
|
|
|
|
use App\Models\Node;
|
|
use App\Models\User;
|
|
|
|
class NodePolicy
|
|
{
|
|
use DefaultPolicies;
|
|
|
|
protected string $modelName = 'node';
|
|
|
|
public function before(User $user, string $ability, string|Node $node): ?bool
|
|
{
|
|
// For "viewAny" the $node param is the class name
|
|
if (is_string($node)) {
|
|
return null;
|
|
}
|
|
|
|
if (!$user->canTarget($node)) {
|
|
return false;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|