Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0e68d9dbe7 | ||
| 19ac37fb3e | |||
|
|
7e967a1649 | ||
| f5ab0335f9 | |||
|
|
44e1e4a293 | ||
| ad92a4c434 | |||
|
|
be12175e17 | ||
| e8fc85c173 |
1
.env
1
.env
@@ -48,5 +48,4 @@ DATABASE_URL="postgresql://app:!ChangeMe!@127.0.0.1:5432/app?serverVersion=16&ch
|
|||||||
SIRH_MAINTENANCE_PATH=/var/www/maintenance/sirh/maintenance.on
|
SIRH_MAINTENANCE_PATH=/var/www/maintenance/sirh/maintenance.on
|
||||||
LESSTIME_MAINTENANCE_PATH=/var/www/maintenance/lesstime/maintenance.on
|
LESSTIME_MAINTENANCE_PATH=/var/www/maintenance/lesstime/maintenance.on
|
||||||
INVENTORY_MAINTENANCE_PATH=/var/www/maintenance/inventory/maintenance.on
|
INVENTORY_MAINTENANCE_PATH=/var/www/maintenance/inventory/maintenance.on
|
||||||
FERME_MAINTENANCE_PATH=/var/www/maintenance/ferme/maintenance.on
|
|
||||||
###< malio/maintenance ###
|
###< malio/maintenance ###
|
||||||
|
|||||||
@@ -3,4 +3,3 @@ parameters:
|
|||||||
- { name: 'SIRH', slug: 'sirh', maintenance_path: '%env(SIRH_MAINTENANCE_PATH)%' }
|
- { name: 'SIRH', slug: 'sirh', maintenance_path: '%env(SIRH_MAINTENANCE_PATH)%' }
|
||||||
- { name: 'Lesstime', slug: 'lesstime', maintenance_path: '%env(LESSTIME_MAINTENANCE_PATH)%' }
|
- { name: 'Lesstime', slug: 'lesstime', maintenance_path: '%env(LESSTIME_MAINTENANCE_PATH)%' }
|
||||||
- { name: 'Inventory', slug: 'inventory', maintenance_path: '%env(INVENTORY_MAINTENANCE_PATH)%' }
|
- { name: 'Inventory', slug: 'inventory', maintenance_path: '%env(INVENTORY_MAINTENANCE_PATH)%' }
|
||||||
- { name: 'Ferme', slug: 'ferme', maintenance_path: '%env(FERME_MAINTENANCE_PATH)%' }
|
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
parameters:
|
parameters:
|
||||||
app.version: '0.1.3'
|
app.version: '0.1.7'
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export function useAppVersion() {
|
|||||||
if (version.value) {
|
if (version.value) {
|
||||||
return version.value
|
return version.value
|
||||||
}
|
}
|
||||||
const response = await api.get<{ version: string }>('version', {}, {
|
const response = await api.get<{ version: string }>('/version', {}, {
|
||||||
toast: false
|
toast: false
|
||||||
})
|
})
|
||||||
version.value = response.version
|
version.value = response.version
|
||||||
|
|||||||
@@ -28,9 +28,11 @@ use Symfony\Component\Serializer\Attribute\Groups;
|
|||||||
normalizationContext: ['groups' => ['me:read']],
|
normalizationContext: ['groups' => ['me:read']],
|
||||||
),
|
),
|
||||||
new Get(
|
new Get(
|
||||||
|
security: "is_granted('ROLE_ADMIN')",
|
||||||
normalizationContext: ['groups' => ['user:list']],
|
normalizationContext: ['groups' => ['user:list']],
|
||||||
),
|
),
|
||||||
new GetCollection(
|
new GetCollection(
|
||||||
|
security: "is_granted('ROLE_ADMIN')",
|
||||||
normalizationContext: ['groups' => ['user:list']],
|
normalizationContext: ['groups' => ['user:list']],
|
||||||
),
|
),
|
||||||
new Post(security: "is_granted('ROLE_ADMIN')", processor: UserPasswordHasherProcessor::class),
|
new Post(security: "is_granted('ROLE_ADMIN')", processor: UserPasswordHasherProcessor::class),
|
||||||
|
|||||||
@@ -44,13 +44,17 @@ final readonly class MaintenanceToggleProcessor implements ProcessorInterface
|
|||||||
if ($data->maintenance) {
|
if ($data->maintenance) {
|
||||||
$directory = dirname($maintenancePath);
|
$directory = dirname($maintenancePath);
|
||||||
|
|
||||||
if (!is_dir($directory)) {
|
if (!is_dir($directory) && !mkdir($directory, 0755, true)) {
|
||||||
mkdir($directory, 0755, true);
|
throw new \RuntimeException(sprintf('Cannot create directory "%s".', $directory));
|
||||||
}
|
}
|
||||||
|
|
||||||
touch($maintenancePath);
|
if (!touch($maintenancePath)) {
|
||||||
|
throw new \RuntimeException(sprintf('Cannot create maintenance file at "%s".', $maintenancePath));
|
||||||
|
}
|
||||||
} elseif (file_exists($maintenancePath)) {
|
} elseif (file_exists($maintenancePath)) {
|
||||||
unlink($maintenancePath);
|
if (!unlink($maintenancePath)) {
|
||||||
|
throw new \RuntimeException(sprintf('Cannot remove maintenance file at "%s".', $maintenancePath));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$dto = new ManagedApplication();
|
$dto = new ManagedApplication();
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use ApiPlatform\Metadata\Operation;
|
|||||||
use ApiPlatform\State\ProviderInterface;
|
use ApiPlatform\State\ProviderInterface;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
use Symfony\Bundle\SecurityBundle\Security;
|
use Symfony\Bundle\SecurityBundle\Security;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @implements ProviderInterface<User>
|
* @implements ProviderInterface<User>
|
||||||
@@ -20,7 +21,12 @@ final readonly class MeProvider implements ProviderInterface
|
|||||||
|
|
||||||
public function provide(Operation $operation, array $uriVariables = [], array $context = []): User
|
public function provide(Operation $operation, array $uriVariables = [], array $context = []): User
|
||||||
{
|
{
|
||||||
// @var User $user
|
$user = $this->security->getUser();
|
||||||
return $this->security->getUser();
|
|
||||||
|
if (!$user instanceof User) {
|
||||||
|
throw new AccessDeniedHttpException('User not authenticated.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user