Allow public raw snips to be accessed without account

This commit is contained in:
Tim
2023-04-08 17:58:14 +02:00
parent 47167a3e1e
commit 669cbfdaca
3 changed files with 12 additions and 8 deletions

View File

@ -4,6 +4,7 @@ namespace App\Service;
use App\Entity\User;
use App\Git\CustomGitRepository;
use Symfony\Component\Security\Core\User\UserInterface;
class SnipService
{
@ -12,7 +13,7 @@ class SnipService
public function __construct(
private readonly CustomGitRepository $repo,
private readonly User $user,
private readonly ?User $user,
)
{
}
@ -29,6 +30,9 @@ class SnipService
public function update(string $snipContents): void
{
if (!$this->user instanceof UserInterface) {
return;
}
if ($this->repo->getCurrentBranchName() !== self::MASTER_BRANCH_NAME) {
$this->repo->checkout(self::MASTER_BRANCH_NAME);
}
@ -54,6 +58,6 @@ class SnipService
public function deleteRepo(): void
{
system("rm -rf ".escapeshellarg($this->repo->getRepositoryPath()));
system("rm -rf " . escapeshellarg($this->repo->getRepositoryPath()));
}
}