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


PHP Authentication\AuthenticationService类代码示例

本文整理汇总了PHP中Zend\Authentication\AuthenticationService的典型用法代码示例。如果您正苦于以下问题:PHP AuthenticationService类的具体用法?PHP AuthenticationService怎么用?PHP AuthenticationService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: createService

 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $adapter = $serviceLocator->get('auth-adapter');
     $auth = new AuthenticationService();
     $auth->setAdapter($adapter);
     return $auth;
 }
开发者ID:spoorey,项目名称:hangman,代码行数:7,代码来源:AuthenticationFactory.php

示例2: authenticate

 public function authenticate($username, $password)
 {
     $callback = function ($password, $hash) {
         $bcrypt = new Bcrypt();
         return $bcrypt->verify($hash, $password);
     };
     $authenticationService = new AuthenticationService();
     $callbackCheckAdapter = new CallbackCheckAdapter($this->dbAdapter, "users", 'username', 'password', $callback);
     $callbackCheckAdapter->setIdentity($username)->setCredential($password);
     $authenticationService->setAdapter($callbackCheckAdapter);
     $authResult = $authenticationService->authenticate();
     if ($authResult->isValid()) {
         $userObject = $callbackCheckAdapter->getResultRowObject();
         $authenticationService->getStorage()->write($userObject);
         if ($userObject->status == 0) {
             $authenticationService->clearIdentity();
             $this->setCode(-5);
             return false;
         } else {
             return true;
         }
     } else {
         $this->setCode($authResult->getCode());
         return false;
     }
 }
开发者ID:kalelc,项目名称:inventory,代码行数:26,代码来源:AuthSessionAdapter.php

示例3: logoutAction

 public function logoutAction()
 {
     $auth = new AuthenticationService();
     $auth->setStorage(new SessionStorage("geframa_admin"));
     $auth->clearIdentity();
     return $this->redirect()->toRoute('geframa_login');
 }
开发者ID:phtfao,项目名称:geframa,代码行数:7,代码来源:LoginController.php

示例4: logoutAction

 /**
  * Logout user
  *
  * @return \Zend\Http\Response
  */
 public function logoutAction()
 {
     $auth = new AuthenticationService();
     $auth->setStorage(new SessionStorage('BookstoreAdmin'));
     $auth->clearIdentity();
     return $this->redirect()->toRoute('bookstore-admin-auth');
 }
开发者ID:argentinaluiz,项目名称:Learning-ZF2,代码行数:12,代码来源:AuthController.php

示例5: get_auth

 /**
  * @return string 用户名字符串
  * 如果没有登录,返回null
  */
 public static function get_auth()
 {
     $auth = new AuthenticationService();
     $tmp = $auth->getStorage()->read();
     return $tmp;
     //返回一个类,有username和schoolID和userID和type这四个在userservice里面get——auth函数里write数据库中的两列。
 }
开发者ID:pengtt0119,项目名称:CotestWeb_,代码行数:11,代码来源:WAuthUtil.php

示例6: validaAuth

 public function validaAuth($e)
 {
     $auth = new AuthenticationService();
     $auth->setStorage(new SessionStorage("SONUSer"));
     $controller = $e->getTarget();
     $matchedRoute = $controller->getEvent()->getRouteMatch()->getMatchedRouteName();
 }
开发者ID:feijojr,项目名称:EADGestao,代码行数:7,代码来源:Module.php

示例7: addAction

 public function addAction()
 {
     $viewModel = new ViewModel();
     $form = $this->getServiceLocator()->get("Process\\Form\\ReceiveInventoryForm");
     $viewModel->setVariable('form', $form);
     $request = $this->getRequest();
     if ($request->isPost()) {
         $receiveInventory = new ReceiveInventory();
         $form->setInputFilter($receiveInventory->getInputFilter());
         $data = $request->getPost()->toArray();
         $form->setData($data);
         if ($form->isValid()) {
             $fileService = $this->getServiceLocator()->get('Admin\\Service\\FileService');
             $fileService->setDestination($this->config['component']['receive_inventory']['file_path']);
             $fileService->setSize($this->config['file_characteristics']['file']['size']);
             $fileService->setExtension($this->config['file_characteristics']['file']['extension']);
             $invoiceFile = $fileService->copy($this->params()->fromFiles('invoice_file'));
             $data['invoice_file'] = $invoiceFile ? $invoiceFile : "";
             $authenticationService = new AuthenticationService();
             $user = $authenticationService->getStorage()->read()->id;
             $receiveInventory->setUser($user);
             $receiveInventory->exchangeArray($data);
             $receiveInventoryId = $this->getReceiveInventoryTable()->save($receiveInventory);
             $container = new Container('receive_inventory');
             $container->id = $receiveInventoryId;
             $container->user = $user;
             return $this->redirect()->toRoute('process/receive_inventory/add/details');
         }
     }
     $viewModel->setVariable('config', $this->config);
     return $viewModel;
 }
开发者ID:kalelc,项目名称:inventory,代码行数:32,代码来源:ReceiveInventoryController.php

示例8: indexAction

 public function indexAction()
 {
     /* 	$temp = $this->forward()->dispatch('Application/Controller/Album', array('action' => 'index'));
     		
     		echo '<pre>'; print_r($temp); echo '<pre>';die; */
     $auth = new AuthenticationService();
     if (!$auth->hasIdentity()) {
         return $this->redirect()->toRoute('home');
     }
     $select = new Select();
     $search = @$_REQUEST['search'];
     if (!empty($search)) {
         $select->where->like('name', '%' . $search . '%');
     }
     $order_by = $this->params()->fromRoute('order_by') ? $this->params()->fromRoute('order_by') : 'id';
     $order = $this->params()->fromRoute('order') ? $this->params()->fromRoute('order') : Select::ORDER_ASCENDING;
     $page = $this->params()->fromRoute('page') ? (int) $this->params()->fromRoute('page') : 1;
     $category = $this->getCategoryTable()->fetchAllCategory($select->order($order_by . ' ' . $order), $search);
     $itemPerPage = 2;
     $category->current();
     $paginator = new Paginator(new PaginatorIterator($category));
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage($itemPerPage);
     $paginator->setPageRange(10);
     return new ViewModel(array('order_by' => $order_by, 'order' => $order, 'page' => $page, 'paginator' => $paginator));
 }
开发者ID:anillaogi016,项目名称:zend-admin,代码行数:26,代码来源:CategoryController.php

示例9: checkAcl

 public function checkAcl(MvcEvent $e)
 {
     //guardamos el nombre de la ruta o recurso a permitir o denegar
     $route = $e->getRouteMatch()->getMatchedRouteName();
     //Instanciamos el servicio de autenticacion
     $auth = new AuthenticationService();
     $identi = $auth->getStorage()->read();
     // Establecemos nuestro rol
     // $userRole = 'admin';
     // Si el usuario esta identificado le asignaremos el rol admin y si no el rol visitante.
     if ($identi != false && $identi != null) {
         $userRole = $identi->role;
     } else {
         $userRole = 'visitante';
     }
     /*
     Esto se puede mejorar fácilmente, si tenemos un campo rol en la BD cuando el usuario
     se identifique en la sesión se guardarán todos los datos del mismo, de modo que
     $userRole=$identi->role;
     */
     //Comprobamos si no está permitido para ese rol esa ruta
     if (!$e->getViewModel()->acl->isAllowed($userRole, $route)) {
         //Devolvemos un error 404
         $response = $e->getResponse();
         $response->getHeaders()->addHeaderLine('Location', $e->getRequest()->getBaseUrl() . '/404');
         $response->setStatusCode(404);
     }
 }
开发者ID:patkings,项目名称:ejemploZF2,代码行数:28,代码来源:Module.php

示例10: __construct

 public function __construct(AuthenticationService $authService)
 {
     parent::__construct('login');
     $this->filter = new InputFilter();
     $email = new Element\Email('email');
     $email->setAttribute('required', true);
     $email->setAttribute('placeholder', 'Email Address');
     $this->add($email);
     $emailFilter = new Input('email');
     $emailFilter->setRequired(true);
     $this->filter->add($emailFilter);
     $password = new Element\Password('password');
     $password->setAttribute('required', true);
     $password->setAttribute('placeholder', 'Password');
     $this->add($password);
     $passwordFilter = new Input('password');
     $passwordFilter->setRequired(true);
     $passwordFilter->getValidatorChain()->attach(new AuthValidator\Authentication(array('message' => 'Invalid email address or password', 'service' => $authService, 'adapter' => $authService->getAdapter(), 'identity' => 'email', 'credential' => 'password')));
     $this->filter->add($passwordFilter);
     $buttons = new Form('buttons');
     $buttons->setOption('twb-layout', 'inline');
     $buttons->setAttribute('class', 'form-group');
     $submit = new Element\Submit('submit');
     $submit->setAttribute('class', 'btn-primary pull-right');
     $submit->setOption('glyphicon', 'log-in');
     $submit->setLabel('Log In');
     $buttons->add($submit);
     $forgot = new Element\Submit('forgot');
     $forgot->setAttribute('formnovalidate', true);
     $forgot->setAttribute('class', 'btn-warning pull-right');
     $forgot->setOption('glyphicon', 'question-sign');
     $forgot->setLabel('Forgot Password');
     $buttons->add($forgot);
     $this->add($buttons);
 }
开发者ID:PoetikDragon,项目名称:USCSS,代码行数:35,代码来源:Login.php

示例11: authenticate

 public function authenticate(array $credentials)
 {
     $username = $credentials['username'];
     $password = $credentials['password'];
     $dbAdapter = $this->serviceManager->get('Zend\\Db\\Adapter\\Adapter');
     $dbTableAuthAdapter = new DbTableAuthAdapter($dbAdapter, 'users', 'username', 'password', 'MD5(?)');
     $dbTableAuthAdapter->setIdentity($username);
     $dbTableAuthAdapter->setCredential($password);
     $authService = new AuthenticationService();
     $authService->setAdapter($dbTableAuthAdapter);
     //$authService->setStorage($this->getServiceManager()->get('IdAuth\Storage'));
     $authResult = $authService->authenticate();
     $result = new ProviderResult();
     $result->setAuthCode($authResult->getCode());
     $result->setMessages($authResult->getMessages());
     $result->setValid($authResult->isValid());
     $result->setName('IdAuth\\Providers\\DbTable');
     $config = $this->serviceManager->get('Config');
     $options = $config['idAuth']['providerOptions']['DbTable'];
     $result->setOptions($options);
     if ($authResult->isValid()) {
         $result->setIdentity($this->queryIdentity($username));
     }
     return $result;
 }
开发者ID:neuweb,项目名称:idauth,代码行数:25,代码来源:DbTableProvider.php

示例12: logoutAction

 public function logoutAction()
 {
     $auth = new AuthenticationService();
     //$auth->setStorage(new SessionStorage("ACPLOUser"));
     $auth->clearIdentity();
     return $this->redirect()->toRoute('acplouser-auth');
 }
开发者ID:abelclopes,项目名称:ZF2-Intermediario-com-acl,代码行数:7,代码来源:AuthController.php

示例13: dispatch

 public function dispatch(MvcEvent $event)
 {
     $request = $event->getRequest();
     if ($request instanceof ConsoleRequest) {
         return true;
     }
     $auth = new AuthenticationService();
     //ALREADY LOGGED IN
     //	user has auth,
     if ($auth->hasIdentity()) {
         return true;
         //NOT LOGGED IN
         //
     } else {
         /** @var $request \Zend\Http\PhpEnvironment\Request */
         $cookies = $request->getCookie();
         /** @var $cookies \Zend\Http\Header\Cookie */
         $userService = $this->getServiceLocator()->get('Stjornvisi\\Service\\User');
         /** @var $user \Stjornvisi\Service\User */
         if ($cookies && $cookies->offsetExists('backpfeifengesicht')) {
             if (($user = $userService->getByHash($cookies->offsetGet('backpfeifengesicht'))) != false) {
                 $authAdapter = $this->getServiceLocator()->get('Stjornvisi\\Auth\\Adapter');
                 $authAdapter->setIdentifier($user->id);
                 $result = $auth->authenticate($authAdapter);
                 $result->isValid();
             }
         }
     }
 }
开发者ID:bix0r,项目名称:Stjornvisi,代码行数:29,代码来源:PersistenceLoginListener.php

示例14: createService

 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $authAdapter = $serviceLocator->get("TSCore\\Auth\\Adapter");
     $auth = new AuthenticationService();
     $auth->setAdapter($authAdapter);
     return $auth;
 }
开发者ID:creativewild,项目名称:TS3UI,代码行数:7,代码来源:ServiceFactory.php

示例15: logoutAction

 public function logoutAction()
 {
     $auth = new AuthenticationService();
     $auth->setStorage(new SessionStorage("auth_enquete"));
     $auth->clearIdentity();
     $this->redirect()->toRoute("auth");
 }
开发者ID:felipe1070,项目名称:testeXyz,代码行数:7,代码来源:AuthController.php


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