Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kohinos
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
9
Issues
9
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cooperatic-mlc
kohinos
Commits
ca67eb4f
Commit
ca67eb4f
authored
Jan 22, 2019
by
Julien Jorry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BO : empêcher de modifier et/ou supprimer le role SUPER_ADMIN ou ADMIN_SIEGE
parent
6e750b4f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
23 deletions
+27
-23
UserAdmin.php
src/Application/Sonata/UserBundle/Admin/UserAdmin.php
+26
-22
CRUDController.php
src/Controller/CRUD/CRUDController.php
+1
-1
No files found.
src/Application/Sonata/UserBundle/Admin/UserAdmin.php
View file @
ca67eb4f
...
...
@@ -109,6 +109,7 @@ class UserAdmin extends BaseUserAdmin
*/
protected
function
configureFormFields
(
FormMapper
$formMapper
)
:
void
{
$subject
=
$this
->
getSubject
();
// define group zoning
$formMapper
->
tab
(
'User'
)
...
...
@@ -116,11 +117,13 @@ class UserAdmin extends BaseUserAdmin
->
with
(
'General'
,
[
'class'
=>
'col-md-6'
])
->
end
()
// ->with('Social', ['class' => 'col-md-6'])->end()
->
end
()
->
tab
(
'Security'
)
->
with
(
'Groups'
,
[
'class'
=>
'col-md-8'
])
->
end
()
->
with
(
'Status'
,
[
'class'
=>
'col-md-4'
])
->
end
()
->
tab
(
'Security'
);
if
(
!
(
$subject
->
isGranted
(
'ROLE_SUPER_ADMIN'
)
||
$subject
->
isGranted
(
'ROLE_ADMIN_SIEGE'
)))
{
$formMapper
->
with
(
'Groups'
,
[
'class'
=>
'col-md-8'
])
->
end
();
}
$formMapper
->
with
(
'Status'
,
[
'class'
=>
'col-md-4'
])
->
end
()
// ->with('Keys', ['class' => 'col-md-4'])->end()
->
with
(
'Roles'
,
[
'class'
=>
'col-md-12'
])
->
end
()
//
->with('Roles', ['class' => 'col-md-12'])->end()
->
end
()
;
...
...
@@ -175,27 +178,28 @@ class UserAdmin extends BaseUserAdmin
->
tab
(
'Security'
)
->
with
(
'Status'
)
->
add
(
'enabled'
,
null
,
[
'required'
=>
false
])
->
end
()
->
with
(
'Groups'
)
->
add
(
'groups'
,
ModelType
::
class
,
[
'required'
=>
false
,
'expanded'
=>
true
,
'multiple'
=>
true
,
])
->
end
()
->
with
(
'Roles'
)
->
add
(
'realRoles'
,
SecurityRolesType
::
class
,
[
'label'
=>
'form.label_roles'
,
'expanded'
=>
true
,
'multiple'
=>
true
,
'required'
=>
false
,
])
->
end
()
->
end
();
if
(
!
(
$subject
->
isGranted
(
'ROLE_SUPER_ADMIN'
)
||
$subject
->
isGranted
(
'ROLE_ADMIN_SIEGE'
)))
{
$formMapper
->
with
(
'Groups'
)
->
add
(
'groups'
,
ModelType
::
class
,
[
'required'
=>
false
,
'expanded'
=>
true
,
'multiple'
=>
true
,
])
->
end
();
}
// ->with('Roles')
// ->add('realRoles', SecurityRolesType::class, [
// 'label' => 'form.label_roles',
// 'expanded' => true,
// 'multiple' => true,
// 'required' => false,
// ])
// ->end()
// ->with('Keys')
// ->add('token', null, ['required' => false])
// ->add('twoStepVerificationCode', null, ['required' => false])
// ->end()
->
end
()
;
$formMapper
->
end
();
}
}
src/Controller/CRUD/CRUDController.php
View file @
ca67eb4f
...
...
@@ -27,7 +27,7 @@ class CRUDController extends Controller
return
$this
->
redirectTo
(
$object
);
}
if
(
$object
->
hasRo
a
le
(
'ROLE_SUPER_ADMIN'
)
||
$object
->
hasRole
(
'ROLE_ADMIN_SIEGE'
))
{
if
(
$object
->
hasRole
(
'ROLE_SUPER_ADMIN'
)
||
$object
->
hasRole
(
'ROLE_ADMIN_SIEGE'
))
{
$this
->
addFlash
(
'sonata_flash_error'
,
'Vous ne pouvez pas supprimer le compte admin !'
...
...
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