mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-05 07:52:34 +00:00
Add site redirects (#552)
* feat(redirects): add redirects to sites * chore(style): fixed coding style issues * style: fix php-stan docblocks * style: pint cleanup * tests: fixed redirect test suite * feat: vhosts include additional configs * fix: use exact location matching * - add enums - use queues - use vhost rather than separate conf files - vhost formatter - cleanup * generate docs --------- Co-authored-by: Saeed Vaziry <mr.saeedvaziry@gmail.com>
This commit is contained in:
35
app/Policies/RedirectPolicy.php
Normal file
35
app/Policies/RedirectPolicy.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Models\Site;
|
||||
use App\Models\User;
|
||||
|
||||
class RedirectPolicy
|
||||
{
|
||||
public function view(User $user, Site $site, Server $server): bool
|
||||
{
|
||||
if ($user->isAdmin()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $site->server->project->users->contains($user);
|
||||
}
|
||||
|
||||
public function create(User $user, Site $site, Server $server): bool
|
||||
{
|
||||
return ($user->isAdmin() || $site->server->project->users->contains($user))
|
||||
&& $site->server_id === $server->id
|
||||
&& $site->server->isReady()
|
||||
&& $site->server->webserver();
|
||||
}
|
||||
|
||||
public function delete(User $user, Site $site, Server $server): bool
|
||||
{
|
||||
return ($user->isAdmin() || $site->server->project->users->contains($user))
|
||||
&& $site->server_id === $server->id
|
||||
&& $site->server->isReady()
|
||||
&& $site->server->webserver();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user