Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
jehba
ddec-info-ng
Commits
1eb56b29
Commit
1eb56b29
authored
May 04, 2019
by
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
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
src/Entity/Lizmap/LizmapUser.php
View file @
1eb56b29
...
...
@@ -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
src/EventListener/LizmapUserLoadListener.php
View file @
1eb56b29
...
...
@@ -26,6 +26,7 @@ class LizmapUserLoadListener
if
(
$ddecInfoUser
!==
null
)
{
$entity
->
setRoles
(
$ddecInfoUser
->
getRoles
());
$entity
->
setAdmin
(
$ddecInfoUser
->
isAdmin
());
}
}
}
\ No newline at end of file
src/Form/UserType.php
View file @
1eb56b29
...
...
@@ -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
,
[
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment