diff --git a/lib/Alchemy/Phrasea/Authentication/Authenticator.php b/lib/Alchemy/Phrasea/Authentication/Authenticator.php index 71ec4afbc4..2d8c636886 100644 --- a/lib/Alchemy/Phrasea/Authentication/Authenticator.php +++ b/lib/Alchemy/Phrasea/Authentication/Authenticator.php @@ -64,8 +64,6 @@ class Authenticator $this->session->remove('usr_id'); $this->session->remove('session_id'); - $this->session->set('usr_id', $user->get_id()); - $session = new Session(); $session->setBrowserName($this->browser->getBrowser()) ->setBrowserVersion($this->browser->getVersion()) @@ -76,7 +74,7 @@ class Authenticator $this->em->persist($session); $this->em->flush(); - $this->session->set('session_id', $session->getId()); + $this->populateSession($session); foreach ($this->app['acl']->get($user)->get_granted_sbas() as $databox) { \cache_databox::insertClient($this->app, $databox); @@ -86,6 +84,20 @@ class Authenticator return $session; } + private function populateSession(Session $session) + { + $user = $session->getUser($this->app); + + $rights = []; + if ($this->app['acl']->get($user)->has_right('taskmanager')) { + $rights[] = 'task-manager'; + } + + $this->session->set('usr_id', $user->get_id()); + $this->session->set('websockets_rights', $rights); + $this->session->set('session_id', $session->getId()); + } + public function refreshAccount(Session $session) { if (!$this->em->getRepository('Alchemy\Phrasea\Model\Entities\Session')->findOneBy(['id' => $session->getId()])) { @@ -99,8 +111,7 @@ class Authenticator } $this->session->clear(); - $this->session->set('usr_id', $session->getUsrId()); - $this->session->set('session_id', $session->getId()); + $this->populateSession($session); foreach ($this->app['acl']->get($user)->get_granted_sbas() as $databox) { \cache_databox::insertClient($this->app, $databox);