示例#1
0
 /**
  * Handle login form
  *
  * @return array|\Zend\Http\Response array (form => \Console\Form\Login) or redirect response
  */
 public function loginAction()
 {
     // Don't show the login form if the user is already logged in
     if ($this->_authenticationService->hasIdentity()) {
         return $this->redirectToRoute('client');
     }
     $vars = array('form' => $this->_form);
     if ($this->getRequest()->isPost()) {
         $this->_form->setData($this->params()->fromPost());
         if ($this->_form->isValid()) {
             // Check credentials
             $data = $this->_form->getData();
             if ($this->_authenticationService->login($data['User'], $data['Password'])) {
                 // Authentication successful. Redirect to appropriate page.
                 $session = new \Zend\Session\Container('login');
                 if (isset($session->originalUri)) {
                     // We got redirected here from another page. Redirect to original page.
                     $response = $this->redirect()->toUrl($session->originalUri);
                 } else {
                     // Redirect to default page (client listing)
                     $response = $this->redirectToRoute('client');
                 }
                 $session->getManager()->getStorage()->clear('login');
                 return $response;
             }
         }
         $vars['invalidCredentials'] = true;
     }
     return $vars;
 }
示例#2
0
 /**
  * 登出
  *
  * @return \Zend\Http\Response
  */
 public function logoutAction()
 {
     if (!$this->getAuthService()->getIdentity()) {
         return $this->redirect()->toRoute('home');
     }
     $username = $this->getAuthService()->getIdentity()->getUsername();
     //   $this->getSessionStorage()->forgetMe();
     $this->getAuthService()->clearIdentity();
     $httpIp = $this->getRequest()->getServer('REMOTE_ADDR');
     $this->getServiceLocator()->get('Zend\\Log')->info($username . ' logout from ' . $httpIp);
     // $this->flashmessenger()->addMessage("您已經登出");
     $session = new \Zend\Session\Container('user');
     $session->getManager()->destroy();
     /*   $session = $this->getServiceLocator()->get('SchoolSession');
          $session->getManager()->destroy();*/
     return $this->redirect()->toRoute('home');
 }
示例#3
0
                    case 1409011510:
                        $control->addValidationMessage('username_register', 'Utente già autenticato');
                        break;
                    default:
                        throw $e;
                        break;
                }
            }
            $auth->getStorage()->clear();
            if (is_numeric(session_id())) {
                session_destroy();
            }
        } else {
            if (array_key_exists('logout', $_REQUEST)) {
                $auth->getStorage()->clear();
                $facebookSession->getManager()->getStorage()->clear('facebook_id');
                if (is_numeric(session_id())) {
                    session_destroy();
                }
                header('Location: ' . $GLOBALS['db']->config->baseUrl);
                exit;
            }
        }
    }
}
$profile = null;
try {
    $user = login\user\LoginInstantiator::getLoginInstance($db, $auth->getStorage()->read());
    if (is_object($user)) {
        $profile = $user->getProfile();
    } else {
示例#4
0
 public function logoutAction()
 {
     $loginaccess = new \Zend\Session\Container('myacl');
     $loginaccess->getManager()->getStorage()->clear('myacl');
     //return $this->redirect()->toRoute('Login');
 }