Fixed Deprecations: EasyAdmin and Symfony Security
CI / Docker Lint (push) Successful in 31s

This commit is contained in:
2025-10-23 22:13:19 +02:00
parent 850e8afaa1
commit fe2bc7b78c
3 changed files with 12 additions and 10 deletions
+9 -9
View File
@@ -28,18 +28,18 @@ class UserCrudController extends AbstractCrudController
public function configureFields(string $pageName): iterable
{
yield TextField::new ('username');
yield TextField::new ('username')->onlyWhenUpdating()->setDisabled(true);
yield TextField::new('username');
yield TextField::new('username')->onlyWhenUpdating()->setDisabled(true);
$availableRoles = ['User' => 'ROLE_USER', 'Admin' => 'ROLE_ADMIN', 'Test' => 'ROLE_TEST', 'SuperAdmin' => 'ROLE_SUPERADMIN'];
yield ChoiceField::new ('roles')
yield ChoiceField::new('roles')
->setChoices($availableRoles)
->allowMultipleChoices(true);
yield FormField::addPanel('Set password')->setIcon('fa fa-key');
yield FormField::addFieldset('Set password')->setIcon('fa fa-key');
$fieldPassword = Field::new ('plainPassword', 'New password')
$fieldPassword = Field::new('plainPassword', 'New password')
->hideOnIndex()
->setRequired(false)
->setFormType(RepeatedType::class)
@@ -50,7 +50,7 @@ class UserCrudController extends AbstractCrudController
'error_bubbling' => true,
'invalid_message' => 'The password fields do not match.',
]);
if($pageName == Crud::PAGE_NEW) {
if ($pageName == Crud::PAGE_NEW) {
$fieldPassword->setRequired(true);
}
@@ -65,10 +65,10 @@ class UserCrudController extends AbstractCrudController
{
//Hash password on creation.
$plaintextPassword = $entityInstance->getPlainPassword();
$hashedPassword = $this->userPasswordHasher->hashPassword($entityInstance, $plaintextPassword);
$entityInstance->setPassword($hashedPassword);
parent::updateEntity($entityManager, $entityInstance);
}
@@ -79,7 +79,7 @@ class UserCrudController extends AbstractCrudController
{
$plaintextPassword = $entityInstance->getPlainPassword();
if($plaintextPassword && $plaintextPassword != "") {
if ($plaintextPassword && $plaintextPassword != "") {
//New password set. Hash password.
$hashedPassword = $this->userPasswordHasher->hashPassword($entityInstance, $plaintextPassword);
$entityInstance->setPassword($hashedPassword);
+2
View File
@@ -4,6 +4,7 @@ namespace App\Entity;
use App\Enum\UserRoleEnum;
use App\Repository\UserRepository;
use Deprecated;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
@@ -120,6 +121,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
/**
* @see UserInterface
*/
#[Deprecated("Not used after Symfony 7.3")]
public function eraseCredentials(): void
{
// If you store any temporary, sensitive data on the user, clear it here
+1 -1
View File
@@ -1,7 +1,7 @@
{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #}
{# @var field \EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto #}
{# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #}
{% if ea.crud.currentAction == 'detail' %}
{% if ea().crud.currentAction == 'detail' %}
<div class="field-icon-div d-flex gap-3">
<span title="{{ field.value }}">{{ field.formattedValue|raw }}</span>
<div class="badge text-bg-secondary">