Initial Ladill Hosting app with Gitea deploy pipeline.
Deploy Ladill Hosting / deploy (push) Failing after 17s
Deploy Ladill Hosting / deploy (push) Failing after 17s
Shared web hosting extracted from the platform monolith, with CI deploy to /var/www/ladill-hosting matching Bird/Domains/Email. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\HostingAccount;
|
||||
use App\Models\User;
|
||||
|
||||
class HostingAccountPolicy
|
||||
{
|
||||
public function viewAccount(User $user, HostingAccount $account): bool
|
||||
{
|
||||
return $this->isOwner($user, $account);
|
||||
}
|
||||
|
||||
public function viewPanel(User $user, HostingAccount $account): bool
|
||||
{
|
||||
return $this->isOwner($user, $account) || $this->isDeveloper($user, $account);
|
||||
}
|
||||
|
||||
public function manageFiles(User $user, HostingAccount $account): bool
|
||||
{
|
||||
return $this->viewPanel($user, $account);
|
||||
}
|
||||
|
||||
public function deleteFiles(User $user, HostingAccount $account): bool
|
||||
{
|
||||
return $this->viewPanel($user, $account);
|
||||
}
|
||||
|
||||
public function viewDomains(User $user, HostingAccount $account): bool
|
||||
{
|
||||
return $this->viewPanel($user, $account);
|
||||
}
|
||||
|
||||
public function manageDomains(User $user, HostingAccount $account): bool
|
||||
{
|
||||
return $this->viewPanel($user, $account);
|
||||
}
|
||||
|
||||
public function manageDatabases(User $user, HostingAccount $account): bool
|
||||
{
|
||||
return $this->viewPanel($user, $account);
|
||||
}
|
||||
|
||||
public function managePhp(User $user, HostingAccount $account): bool
|
||||
{
|
||||
return $this->viewPanel($user, $account);
|
||||
}
|
||||
|
||||
public function useTerminal(User $user, HostingAccount $account): bool
|
||||
{
|
||||
return $this->viewPanel($user, $account);
|
||||
}
|
||||
|
||||
public function manageSsl(User $user, HostingAccount $account): bool
|
||||
{
|
||||
return $this->viewPanel($user, $account);
|
||||
}
|
||||
|
||||
public function manageCron(User $user, HostingAccount $account): bool
|
||||
{
|
||||
return $this->viewPanel($user, $account);
|
||||
}
|
||||
|
||||
public function viewLogs(User $user, HostingAccount $account): bool
|
||||
{
|
||||
return $this->viewPanel($user, $account);
|
||||
}
|
||||
|
||||
public function clearLogs(User $user, HostingAccount $account): bool
|
||||
{
|
||||
return $this->viewPanel($user, $account);
|
||||
}
|
||||
|
||||
public function manageApps(User $user, HostingAccount $account): bool
|
||||
{
|
||||
return $this->viewPanel($user, $account);
|
||||
}
|
||||
|
||||
public function viewSettings(User $user, HostingAccount $account): bool
|
||||
{
|
||||
return $this->viewPanel($user, $account);
|
||||
}
|
||||
|
||||
public function manageSettings(User $user, HostingAccount $account): bool
|
||||
{
|
||||
return $this->isOwner($user, $account);
|
||||
}
|
||||
|
||||
public function changePassword(User $user, HostingAccount $account): bool
|
||||
{
|
||||
return $this->isOwner($user, $account);
|
||||
}
|
||||
|
||||
private function isOwner(User $user, HostingAccount $account): bool
|
||||
{
|
||||
return (int) $account->user_id === (int) $user->id;
|
||||
}
|
||||
|
||||
private function isDeveloper(User $user, HostingAccount $account): bool
|
||||
{
|
||||
if ($this->isOwner($user, $account)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($account->relationLoaded('teamMembers')) {
|
||||
return $account->teamMembers->contains('user_id', $user->id);
|
||||
}
|
||||
|
||||
return $account->teamMembers()
|
||||
->where('user_id', $user->id)
|
||||
->exists();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user