Skip to content

Commit

Permalink
Se agregó control de instancia administrada temporal, desde el select…
Browse files Browse the repository at this point in the history
…or de instancia secundaria
  • Loading branch information
jogianotti committed May 20, 2016
1 parent 5260c4d commit 30fd392
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ public function adminAction($id)
$this->get('session')->set('instance_url', $entity->getUrl());
$this->get('session')->set('instance_host', $entity->getHost());

$this->get('session')->set('admin_instance', $this->get('celsius3_core.instance_helper')->getSessionOrUrlInstance());

return $this->redirect($this->generateUrl('administration'));
}

Expand Down
7 changes: 5 additions & 2 deletions src/Celsius3/CoreBundle/Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,12 @@ public function changeContextAction($id)
$this->get('session')->set('instance_url', $instance->getUrl());
$this->get('session')->set('instance_host', $instance->getHost());

if ($user->getSecondaryInstances()){
$user->setRoles($user->getSecondaryInstances()[$id]);
if ($this->get('session')->get('admin_instance')) {
$this->get('session')->remove('admin_instance');
}

if ($user->getSecondaryInstances()) {
$user->setRoles($user->getSecondaryInstances()[$id]);
}

$token = new \Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
{% if app.session.get('admin_instance') is not empty %}
{{ app.user.addSecondaryInstance(app.session.get('admin_instance'), ['ROLE_ADMIN']) }}
{{ app.session.set('temp_instance', app.session.get('admin_instance')) }}
{% elseif app.session.get('temp_instance') is not empty %}
{{ app.user.removeSecondaryInstance(app.session.get('temp_instance')) }}
{{ app.session.remove('temp_instance') }}
{% endif %}

{% set secondaryInstances = app.user ? app.user.getSecondaryInstances() : null %}

{% if secondaryInstances is not empty %}
Expand Down

0 comments on commit 30fd392

Please sign in to comment.