当前位置: 首页>>代码示例>>PHP>>正文


PHP Application::getAuthenticator方法代码示例

本文整理汇总了PHP中Alchemy\Phrasea\Application::getAuthenticator方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::getAuthenticator方法的具体用法?PHP Application::getAuthenticator怎么用?PHP Application::getAuthenticator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Alchemy\Phrasea\Application的用法示例。


在下文中一共展示了Application::getAuthenticator方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: redirectOnLogRequests

 /**
  * @param Request            $request
  * @param PhraseaApplication $app
  * @return RedirectResponse|null
  */
 public function redirectOnLogRequests(Request $request, PhraseaApplication $app)
 {
     if (!$request->query->has('LOG')) {
         return null;
     }
     if ($app->getAuthenticator()->isAuthenticated()) {
         $app->getAuthenticator()->closeAccount();
     }
     if (null === ($token = $app['repo.tokens']->findValidToken($request->query->get('LOG')))) {
         $app->addFlash('error', $app->trans('The URL you used is out of date, please login'));
         return $app->redirectPath('homepage');
     }
     /** @var Token $token */
     $app->getAuthenticator()->openAccount($token->getUser());
     switch ($token->getType()) {
         case TokenManipulator::TYPE_FEED_ENTRY:
             return $app->redirectPath('lightbox_feed_entry', ['entry_id' => $token->getData()]);
         case TokenManipulator::TYPE_VALIDATE:
         case TokenManipulator::TYPE_VIEW:
             return $app->redirectPath('lightbox_validation', ['basket' => $token->getData()]);
     }
     return null;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:28,代码来源:Lightbox.php

示例2: updateClientInfos

 public static function updateClientInfos(Application $app, $appId)
 {
     if (!$app->getAuthenticator()->isAuthenticated()) {
         return;
     }
     $session = $app['repo.sessions']->find($app['session']->get('session_id'));
     if (!$session) {
         throw new SessionNotFound('No session found');
     }
     if (!$session->hasModuleId($appId)) {
         $module = new SessionModule();
         $module->setModuleId($appId);
         $module->setSession($session);
         $session->addModule($module);
         $app['orm.em']->persist($module);
         $app['orm.em']->persist($session);
         $app['orm.em']->flush();
     }
     $appName = ['1' => 'Prod', '2' => 'Client', '3' => 'Admin', '4' => 'Report', '5' => 'Thesaurus', '6' => 'Compare', '7' => 'Validate', '8' => 'Upload', '9' => 'API'];
     if (isset($appName[$appId])) {
         $sbas_ids = array_keys($app->getAclForUser($app->getAuthenticatedUser())->get_granted_sbas());
         foreach ($sbas_ids as $sbas_id) {
             try {
                 $logger = $app['phraseanet.logger']($app->findDataboxById($sbas_id));
                 $databox = $app->findDataboxById($sbas_id);
                 $connbas = $databox->get_connection();
                 $sql = 'SELECT appli FROM log WHERE id = :log_id';
                 $stmt = $connbas->prepare($sql);
                 $stmt->execute([':log_id' => $logger->get_id()]);
                 $row3 = $stmt->fetch(PDO::FETCH_ASSOC);
                 $stmt->closeCursor();
                 if (!$row3) {
                     throw new Exception('no log');
                 }
                 $applis = unserialize($row3['appli']);
                 if (!in_array($appId, $applis)) {
                     $applis[] = $appId;
                 }
                 $sql = 'UPDATE log SET appli = :applis WHERE id = :log_id';
                 $params = [':applis' => serialize($applis), ':log_id' => $logger->get_id()];
                 $stmt = $connbas->prepare($sql);
                 $stmt->execute($params);
                 $stmt->closeCursor();
             } catch (\Exception $e) {
             }
         }
     }
     return;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:49,代码来源:Logger.php

示例3: logoutUser

 private function logoutUser(Application $app)
 {
     $app->getAuthenticator()->closeAccount();
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:4,代码来源:JsFixtures.php

示例4: fromRequest

 /**
  * Creates options based on a Symfony Request object
  *
  * @param Application $app
  * @param Request     $request
  *
  * @return static
  */
 public static function fromRequest(Application $app, Request $request)
 {
     $options = new static();
     $options->disallowBusinessFields();
     $options->setLocale($app['locale']);
     /** @var Authenticator $authenticator */
     $authenticator = $app->getAuthenticator();
     $isAuthenticated = $authenticator->isAuthenticated();
     /** @var ACLProvider $aclProvider */
     $aclProvider = $app['acl'];
     $acl = $isAuthenticated ? $aclProvider->get($authenticator->getUser()) : null;
     $selected_bases = $request->get('bases');
     if (is_array($selected_bases)) {
         $bas = [];
         foreach ($selected_bases as $bas_id) {
             try {
                 $bas[$bas_id] = \collection::get_from_base_id($app, $bas_id);
             } catch (\Exception_Databox_CollectionNotFound $e) {
                 // Ignore
             }
         }
     } elseif (!$isAuthenticated) {
         $bas = $app->getOpenCollections();
     } else {
         $bas = $acl->get_granted_base();
     }
     // Filter out not found collections
     $bas = array_filter($bas);
     if ($acl) {
         $filter = function (\collection $collection) use($acl) {
             return $acl->has_access_to_base($collection->get_base_id());
         };
     } else {
         $openCollections = $app->getOpenCollections();
         $filter = function (\collection $collection) use($openCollections) {
             return in_array($collection, $openCollections);
         };
     }
     /** @var \collection[] $bas */
     $bas = array_filter($bas, $filter);
     if (!empty($selected_bases) && empty($bas)) {
         throw new BadRequestHttpException('No collections match your criteria');
     }
     $options->onCollections($bas);
     if ($isAuthenticated && $acl->has_right('modifyrecord')) {
         $bf = array_filter($bas, function (\collection $collection) use($acl) {
             return $acl->has_right_on_base($collection->get_base_id(), 'canmodifrecord');
         });
         $options->allowBusinessFieldsOn($bf);
     }
     $status = is_array($request->get('status')) ? $request->get('status') : [];
     $fields = is_array($request->get('fields')) ? $request->get('fields') : [];
     if (empty($fields)) {
         // Select all fields (business included)
         foreach ($options->getDataboxes() as $databox) {
             foreach ($databox->get_meta_structure() as $field) {
                 $fields[] = $field->get_name();
             }
         }
         $fields = array_unique($fields);
     }
     $databoxFields = [];
     $databoxes = $options->getDataboxes();
     foreach ($databoxes as $databox) {
         $metaStructure = $databox->get_meta_structure();
         foreach ($fields as $field) {
             try {
                 $databoxField = $metaStructure->get_element_by_name($field);
             } catch (\Exception $e) {
                 continue;
             }
             if ($databoxField) {
                 $databoxFields[] = $databoxField;
             }
         }
     }
     $options->setFields($databoxFields);
     $options->setStatus($status);
     $options->setSearchType($request->get('search_type'));
     $options->setRecordType($request->get('record_type'));
     $min_date = $max_date = null;
     if ($request->get('date_min')) {
         $min_date = \DateTime::createFromFormat('Y/m/d H:i:s', $request->get('date_min') . ' 00:00:00');
     }
     if ($request->get('date_max')) {
         $max_date = \DateTime::createFromFormat('Y/m/d H:i:s', $request->get('date_max') . ' 23:59:59');
     }
     $options->setMinDate($min_date);
     $options->setMaxDate($max_date);
     $databoxDateFields = [];
     foreach ($databoxes as $databox) {
         $metaStructure = $databox->get_meta_structure();
//.........这里部分代码省略.........
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:101,代码来源:SearchEngineOptions.php

示例5: logout

 /**
  * Logout authenticated user from application.
  *
  * @param Application $app
  */
 protected function logout(Application $app)
 {
     $app['session']->clear();
     $app->getAuthenticator()->reinitUser();
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:10,代码来源:PhraseanetTestCase.php


注:本文中的Alchemy\Phrasea\Application::getAuthenticator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。