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>
30 lines
556 B
PHP
30 lines
556 B
PHP
<?php
|
|
|
|
namespace App\Policies;
|
|
|
|
use App\Models\Mount;
|
|
use App\Models\User;
|
|
|
|
class MountPolicy
|
|
{
|
|
use DefaultPolicies;
|
|
|
|
protected string $modelName = 'mount';
|
|
|
|
public function before(User $user, string $ability, string|Mount $mount): ?bool
|
|
{
|
|
// For "viewAny" the $mount param is the class name
|
|
if (is_string($mount)) {
|
|
return null;
|
|
}
|
|
|
|
foreach ($mount->nodes as $node) {
|
|
if (!$user->canTarget($node)) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|