Allow public raw snips to be accessed without account
This commit is contained in:
@ -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()));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user