Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kohinos-tav
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
agplv3
kohinos-tav
Commits
5b393d66
Commit
5b393d66
authored
Sep 23, 2026
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow switching between roles if different roles are all presta/caissier/...
parent
eb287f25
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
10 deletions
+53
-10
fos_ckeditor.yaml
config/packages/fos_ckeditor.yaml
+1
-0
IndexController.php
src/Controller/IndexController.php
+36
-8
menu.html.twig
templates/themes/kohinos/common/menu.html.twig
+16
-2
No files found.
config/packages/fos_ckeditor.yaml
View file @
5b393d66
...
...
@@ -18,6 +18,7 @@ fos_ck_editor:
NumberedList
,
BulletedList
,
-
,
Outdent
,
Indent
,
-
,
Blockquote
,
-
,
Image
,
Link
,
Unlink
,
Table
]
-
[
Format
,
Maximize
,
Source
]
removePlugins
:
'
scayt,wsc,tableselection'
enterMode
:
CKEDITOR.ENTER_BR
filebrowserBrowseRoute
:
admin_sonata_media_media_ckeditor_browser
...
...
src/Controller/IndexController.php
View file @
5b393d66
...
...
@@ -48,6 +48,8 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use
Symfony\Component\Security\Csrf\CsrfTokenManagerInterface
;
use
Symfony\Component\Security\Guard\GuardAuthenticatorHandler
;
use
Symfony\Component\Security\Guard\Token\PostAuthenticationGuardToken
;
use
Symfony\Component\Security\Core\Authentication\Token\SwitchUserToken
;
use
Symfony\Component\Security\Core\Role\SwitchUserRole
;
class
IndexController
extends
AbstractController
{
...
...
@@ -719,8 +721,8 @@ class IndexController extends AbstractController
return
$this
->
redirectToRoute
(
'index'
);
}
/**
* Choix du
presta
géré.
/**
* Choix du
caissier
géré.
*
* @Route("/login/caissier/choice/{usergrpid}/{caissierid}", name="caissier_choice")
* @ParamConverter("group", class="App:Usergroup", options={"mapping": {"usergrpid": "id"}})
...
...
@@ -794,18 +796,44 @@ class IndexController extends AbstractController
$this
->
em
->
persist
(
$this
->
getUser
());
$this
->
em
->
flush
();
}
$token
=
new
PostAuthenticationGuardToken
(
$this
->
getUser
(),
'main'
,
$this
->
getUser
()
->
getRoles
()
);
$this
->
tokenStorage
->
setToken
(
$token
);
$currentToken
=
$this
->
tokenStorage
->
getToken
();
$switchUserRole
=
null
;
if
(
$currentToken
instanceof
SwitchUserToken
)
{
foreach
(
$currentToken
->
getRoles
()
as
$role
)
{
if
(
$role
instanceof
SwitchUserRole
)
{
$switchUserRole
=
$role
;
break
;
}
}
}
$this
->
guard
->
authenticateUserAndHandleSuccess
(
$this
->
getUser
(),
$request
,
$this
->
authenticator
,
'main'
);
// Si le super admin était en impersonation, on réapplique le SwitchUserToken par-dessus
// celui que le guard vient de créer, pour ne pas perdre ROLE_PREVIOUS_ADMIN.
if
(
null
!==
$switchUserRole
)
{
$freshToken
=
$this
->
tokenStorage
->
getToken
();
$roles
=
$freshToken
->
getRoles
();
$roles
[]
=
$switchUserRole
;
$token
=
new
SwitchUserToken
(
$this
->
getUser
(),
$this
->
getUser
()
->
getPassword
(),
'main'
,
$roles
,
$switchUserRole
->
getSource
()
);
$this
->
tokenStorage
->
setToken
(
$token
);
}
else
{
$token
=
$this
->
tokenStorage
->
getToken
();
}
$this
->
session
->
set
(
'_security_main'
,
serialize
(
$token
));
}
}
templates/themes/kohinos/common/menu.html.twig
View file @
5b393d66
...
...
@@ -92,9 +92,23 @@
{%
if
app.user
%}
<a
href=
"
{{
path
(
'myaccount'
)
}}
"
class=
"dropdown-item"
>
{{
'Mon compte'
|
trans
}}
</a>
{%
endif
%}
{%
if
app.user.possiblegroups
|
length
>
1
%}
{%
if
app.user.possiblegroups
|
length
>
1
or
app.user.prestataires
and
app.user.prestataires
|
length
>
1
or
app.user.caissiers
and
app.user.caissiers
|
length
>
1
or
app.user.comptoirsgeres
and
app.user.comptoirsgeres
|
length
>
1
or
app.user.groupesgeres
and
app.user.groupesgeres
|
length
>
1
%}
<a
href=
"#"
class=
"viewChoiceGroup dropdown-item"
>
{{
'Choix du rôle'
|
trans
}}
</a>
{%
endif
%}
{%
endif
%}
{%
if
is_granted
(
'ROLE_PREVIOUS_ADMIN'
)
%}
<a
href=
"
{{
path
(
'index'
)
}}
?_switch_user=_exit"
class=
"dropdown-item"
>
{{
'RETOUR SUPER ADMIN'
|
trans
}}
</a>
{%
endif
%}
...
...
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