Commit 1eb56b29 authored by Baudouin Feildel's avatar Baudouin Feildel
Browse files

Fix edit user page when current user is LizmapUser

parent e93ba70a
Pipeline #488 passed with stage
in 1 minute and 33 seconds
......@@ -106,6 +106,11 @@ class LizmapUser implements UserInterface
*/
private $roles = ['ROLE_USER'];
/**
* @var bool Admin flag loaded from DDEC-Info user
*/
private $admin = false;
public function __construct($login) {
$this->usr_login = $login;
}
......@@ -386,4 +391,12 @@ class LizmapUser implements UserInterface
public function eraseCredentials() {
// Nothing to do
}
public function isAdmin() : bool {
return $this->admin;
}
public function setAdmin(bool $admin) {
$this->admin = $admin;
}
}
\ No newline at end of file
......@@ -26,6 +26,7 @@ class LizmapUserLoadListener
if ($ddecInfoUser !== null) {
$entity->setRoles($ddecInfoUser->getRoles());
$entity->setAdmin($ddecInfoUser->isAdmin());
}
}
}
\ No newline at end of file
......@@ -3,7 +3,10 @@
namespace App\Form;
use App\DoctrineTypes\UserStatus;
use App\Entity\Lizmap\LizmapUser;
use App\Entity\User;
use App\Repository\UserRepository;
use Exception;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
......@@ -16,10 +19,16 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class UserType extends AbstractType
{
private $userRepository;
public function __construct(UserRepository $userRepository) {
$this->userRepository = $userRepository;
}
/**
* @param FormBuilderInterface $builder
* @param array $options
* @throws \Exception
* @throws Exception
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
......@@ -27,8 +36,12 @@ class UserType extends AbstractType
$current_user = $options['current_user'] == null ? new User() : $options['current_user'];
$edited_user = $options['edited_user'] == null ? new User() : $options['edited_user'];
if ($current_user instanceof LizmapUser) {
$current_user = $this->userRepository->fromLizmapUser($current_user);
}
if($create == false && $options['edited_user'] == null)
throw new \Exception();
throw new Exception();
$builder
->add("name", TextType::class, [
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment