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
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
18 deletions
+22
-18
UserAdmin.php
src/Application/Sonata/UserBundle/Admin/UserAdmin.php
+21
-17
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
...
@@ -109,6 +109,7 @@ class UserAdmin extends BaseUserAdmin
*/
*/
protected
function
configureFormFields
(
FormMapper
$formMapper
)
:
void
protected
function
configureFormFields
(
FormMapper
$formMapper
)
:
void
{
{
$subject
=
$this
->
getSubject
();
// define group zoning
// define group zoning
$formMapper
$formMapper
->
tab
(
'User'
)
->
tab
(
'User'
)
...
@@ -116,11 +117,13 @@ class UserAdmin extends BaseUserAdmin
...
@@ -116,11 +117,13 @@ class UserAdmin extends BaseUserAdmin
->
with
(
'General'
,
[
'class'
=>
'col-md-6'
])
->
end
()
->
with
(
'General'
,
[
'class'
=>
'col-md-6'
])
->
end
()
// ->with('Social', ['class' => 'col-md-6'])->end()
// ->with('Social', ['class' => 'col-md-6'])->end()
->
end
()
->
end
()
->
tab
(
'Security'
)
->
tab
(
'Security'
);
->
with
(
'Groups'
,
[
'class'
=>
'col-md-8'
])
->
end
()
if
(
!
(
$subject
->
isGranted
(
'ROLE_SUPER_ADMIN'
)
||
$subject
->
isGranted
(
'ROLE_ADMIN_SIEGE'
)))
{
->
with
(
'Status'
,
[
'class'
=>
'col-md-4'
])
->
end
()
$formMapper
->
with
(
'Groups'
,
[
'class'
=>
'col-md-8'
])
->
end
();
}
$formMapper
->
with
(
'Status'
,
[
'class'
=>
'col-md-4'
])
->
end
()
// ->with('Keys', ['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
()
->
end
()
;
;
...
@@ -175,27 +178,28 @@ class UserAdmin extends BaseUserAdmin
...
@@ -175,27 +178,28 @@ class UserAdmin extends BaseUserAdmin
->
tab
(
'Security'
)
->
tab
(
'Security'
)
->
with
(
'Status'
)
->
with
(
'Status'
)
->
add
(
'enabled'
,
null
,
[
'required'
=>
false
])
->
add
(
'enabled'
,
null
,
[
'required'
=>
false
])
->
end
()
->
end
();
->
with
(
'Groups'
)
if
(
!
(
$subject
->
isGranted
(
'ROLE_SUPER_ADMIN'
)
||
$subject
->
isGranted
(
'ROLE_ADMIN_SIEGE'
)))
{
$formMapper
->
with
(
'Groups'
)
->
add
(
'groups'
,
ModelType
::
class
,
[
->
add
(
'groups'
,
ModelType
::
class
,
[
'required'
=>
false
,
'required'
=>
false
,
'expanded'
=>
true
,
'expanded'
=>
true
,
'multiple'
=>
true
,
'multiple'
=>
true
,
])
])
->
end
()
->
end
();
->
with
(
'Roles'
)
}
->
add
(
'realRoles'
,
SecurityRolesType
::
class
,
[
// ->with('Roles')
'label'
=>
'form.label_roles'
,
// ->add('realRoles', SecurityRolesType::class, [
'expanded'
=>
true
,
// 'label' => 'form.label_roles',
'multiple'
=>
true
,
// 'expanded' => true,
'required'
=>
false
,
// 'multiple' => true,
])
// 'required' => false,
->
end
()
// ])
// ->end()
// ->with('Keys')
// ->with('Keys')
// ->add('token', null, ['required' => false])
// ->add('token', null, ['required' => false])
// ->add('twoStepVerificationCode', null, ['required' => false])
// ->add('twoStepVerificationCode', null, ['required' => false])
// ->end()
// ->end()
->
end
()
$formMapper
->
end
();
;
}
}
}
}
src/Controller/CRUD/CRUDController.php
View file @
ca67eb4f
...
@@ -27,7 +27,7 @@ class CRUDController extends Controller
...
@@ -27,7 +27,7 @@ class CRUDController extends Controller
return
$this
->
redirectTo
(
$object
);
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
(
$this
->
addFlash
(
'sonata_flash_error'
,
'sonata_flash_error'
,
'Vous ne pouvez pas supprimer le compte admin !'
'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