Add AuthenticationServiceProvider

This commit is contained in:
Romain Neutron
2013-02-15 11:08:05 +01:00
parent f5c5aebe22
commit d2bc4f4a23
117 changed files with 610 additions and 535 deletions

View File

@@ -184,12 +184,12 @@ class PhraseaEngine implements SearchEngineInterface
*/
private function checkSession()
{
if (!$this->app['phraseanet.user']) {
if (!$this->app['authentication']->getUser()) {
throw new \RuntimeException('Phrasea currently support only authenticated queries');
}
if (!phrasea_open_session($this->app['session']->get('phrasea_session_id'), $this->app['phraseanet.user']->get_id())) {
if (!$ses_id = phrasea_create_session((string) $this->app['phraseanet.user']->get_id())) {
if (!phrasea_open_session($this->app['session']->get('phrasea_session_id'), $this->app['authentication']->getUser()->get_id())) {
if (!$ses_id = phrasea_create_session((string) $this->app['authentication']->getUser()->get_id())) {
throw new \Exception_InternalServerError('Unable to create phrasea session');
}
$this->app['session']->set('phrasea_session_id', $ses_id);
@@ -557,7 +557,7 @@ class PhraseaEngine implements SearchEngineInterface
$stmt->execute($params);
$stmt->closeCursor();
if ($this->app['phraseanet.user']) {
if ($this->app['authentication']->getUser()) {
\User_Adapter::saveQuery($this->app, $query);
}

View File

@@ -623,15 +623,15 @@ class SearchEngineOptions
$bas = array_map(function($base_id) use ($app) {
return \collection::get_from_base_id($app, $base_id);
}, $request->get('bases'));
} elseif (!$app->isAuthenticated()) {
} elseif (!$app['authentication']->isAuthenticated()) {
$bas = $app->getOpenCollections();
} else {
$bas = $app['phraseanet.user']->ACL()->get_granted_base();
$bas = $app['authentication']->getUser()->ACL()->get_granted_base();
}
$bas = array_filter($bas, function($collection) use ($app) {
if ($app->isAuthenticated()) {
return $app['phraseanet.user']->ACL()->has_right_on_base($collection->get_base_id(), 'canmodifrecord');
if ($app['authentication']->isAuthenticated()) {
return $app['authentication']->getUser()->ACL()->has_right_on_base($collection->get_base_id(), 'canmodifrecord');
} else {
return in_array($collection, $app->getOpenCollections());
}
@@ -645,9 +645,9 @@ class SearchEngineOptions
}
}
if ($app->isAuthenticated() && $app['phraseanet.user']->ACL()->has_right('modifyrecord')) {
if ($app['authentication']->isAuthenticated() && $app['authentication']->getUser()->ACL()->has_right('modifyrecord')) {
$BF = array_filter($bas, function($collection) use ($app) {
return $app['phraseanet.user']->ACL()->has_right_on_base($collection->get_base_id(), 'canmodifrecord');
return $app['authentication']->getUser()->ACL()->has_right_on_base($collection->get_base_id(), 'canmodifrecord');
});
$options->allowBusinessFieldsOn($BF);