Ejemplo n.º 1
0
 public function logout()
 {
     var_dump('logout');
     $ses = new SessionStorage();
     $s = $ses->clear();
     var_dump($s);
 }
Ejemplo n.º 2
0
 public function preDispatch()
 {
     parent::preDispatch();
     if ($this->request->isXmlHttpRequest()) {
         $this->view->setNoLayout();
     } else {
         if (in_array($this->controllerName, array('member', 'zone'))) {
             $this->layout('frontMemberLayout');
         } else {
             $this->layout('frontLayout');
         }
     }
     $this->layout()->setVariable('controllerName', $this->controllerName);
     $this->layout()->setVariable('actionName', $this->actionName);
     $this->layout()->setVariable('adminName', $this->adminInfo['username']);
     $this->checkLogin(self::FRONT_PLATFORM);
     if (!empty($this->memberInfo) && !$this->memberInfoModel->isAvailable($this->memberInfo)) {
         $session = new Session(self::FRONT_PLATFORM);
         $session->clear();
         setcookie('autoCode', '', time(), '/');
         return $this->redirect()->toUrl('/login/do-login');
     }
     if (!empty($this->memberInfo)) {
         if ($this->controllerName == 'member' && $this->actionName == 'notification') {
             $this->memberInfo['notReadCount'] = 0;
         } else {
             $this->memberInfo['notReadCount'] = $this->notificationModel->getCount(array('memberID' => $this->memberInfo['memberID'], 'read' => 0));
         }
     }
     $categories = $this->productCategoryModel->select()->toArray();
     $tmp = $this->siteSettingModel->select()->toArray();
     $siteSettings = array();
     foreach ($tmp as $v) {
         if ($v['fieldType'] == 'simpleTextArea') {
             $v['settingValue'] = str_replace(array("\n", "\r\n"), '<br />', $v['settingValue']);
         }
         $siteSettings[$v['settingName']] = $v['settingValue'];
     }
     $siteSettings['qq1'] = $siteSettings['qq'];
     $qq = mt_rand(1, 3);
     if ($qq == 2 && !empty($siteSettings['qq2'])) {
         $siteSettings['qq'] = $siteSettings['qq2'];
     } elseif ($qq == 3 && !empty($siteSettings['qq3'])) {
         $siteSettings['qq'] = $siteSettings['qq3'];
     }
     $userAgent = $_SERVER['HTTP_USER_AGENT'];
     $isIE = 0;
     $isLowIE = 0;
     if (strstr($userAgent, 'MSIE 6') || strstr($userAgent, 'MSIE 7') || strstr($userAgent, 'MSIE 8')) {
         if (strstr($userAgent, 'MSIE 6') || strstr($userAgent, 'MSIE 7')) {
             $isLowIE = 1;
         }
         $isIE = 1;
     }
     $this->siteSettings = $siteSettings;
     $this->layout()->setVariables(array('_memberInfo' => $this->memberInfo, '_categories' => $categories, '_siteSettings' => $siteSettings, '_isIE' => $isIE, '_isLowID' => $isLowIE));
     $this->view->setVariables(array('_memberInfo' => $this->memberInfo, '_categories' => $categories, '_siteSettings' => $siteSettings, '_isIE' => $isIE, '_isLowID' => $isLowIE, '_actionName' => $this->actionName, '_controllerName' => $this->controllerName));
 }
Ejemplo n.º 3
0
 public function testSetGetStorage()
 {
     $identity = mt_rand(1, 100);
     $sessionStorage = new Session();
     $sessionStorage->write($identity);
     $this->testedObject->setStorage($sessionStorage);
     $result = $this->testedObject->getStorage();
     $this->assertInstanceOf(Session::class, $result);
     $this->assertSame($identity, $result->read());
 }
Ejemplo n.º 4
0
 public function authenticate()
 {
     $result = new Result(1, 1, array(1 => 'Witaj ' . $this->username));
     $ses = new SessionStorage();
     $ses->write($result);
     $auth = new AuthenticationService();
     // Use 'someNamespace' instead of 'Zend_Auth'
     $auth->setStorage(new SessionStorage('someNamespace'));
     var_dump($auth->getStorage()->read());
     return $result;
 }
Ejemplo n.º 5
0
 public function registerAction()
 {
     $ses = new SessionStorage();
     var_dump($ses->read());
     $form = new UserForm();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $user = $request->getPost();
         $lola = $this->userService->register($user);
         \Zend\Debug\Debug::dump($lola);
     }
     return array('form' => $form);
 }
Ejemplo n.º 6
0
 /**
  * Constructor
  *
  * @param array $options
  */
 public function __construct($options = array())
 {
     $namespace = $options['namespace'];
     $member = $options['member'];
     $sessionManager = isset($options['session_manager']) ? $options['session_manager'] : Pi::service('session')->manager();
     parent::__construct($namespace, $member, $sessionManager);
     $this->setOptions($options);
 }
Ejemplo n.º 7
0
 protected function mockLogin()
 {
     $userSessionValues = new \stdClass();
     $userSessionValues->id = 2;
     $userSessionValues->username = '******';
     $userSessionValues->role = 'administrator';
     $userSessionModel = new Session();
     $userSessionModel->write($userSessionValues);
     $authService = $this->getMock('Zend\\Authentication\\AuthenticationService');
     //     	$authService->expects($this->any())
     // 			    	->method('getIdentity')
     // 			    	->will($this->returnValue($userSessionModel));
     $authService->expects($this->any())->method('hasIdentity')->will($this->returnValue(true));
     //     	$authService->getStorage()->write($userSessionModel);
     $authService->expects($this->any())->method('getStorage')->will($this->returnValue($userSessionModel));
     $this->getApplicationServiceLocator()->setAllowOverride(true);
     $this->getApplicationServiceLocator()->setService('Zend\\Authentication\\AuthenticationService', $authService);
 }
Ejemplo n.º 8
0
 public function indexAction()
 {
     $authService = $this->GetAuthenticationService();
     if (!$authService->hasIdentity()) {
         //
         //  Set the redirect url in the session
         //
         $sessionContainer = new Container();
         $sessionContainer->redirect_url = $this->getRequest()->getUriString();
         return array('loginForm' => new LoginForm(), 'courseList' => $this->GetCourseModel()->FetchNewestCourseMetadata(6));
     } else {
         $session = new Session();
         $username = $session->read();
         $profileModel = $this->GetProfileModel();
         $profile = $profileModel->FetchProfileByUsername($username);
         $courseModel = $this->GetCourseModel();
         $profileForm = new ProfileForm();
         $profileForm->setData($profile->GetArrayCopy());
         //setting existing data from the database
         //$gradeModel = $this->GetGradeModel();
         return array('user' => $profile, 'myCourseList' => $courseModel->FetchMyCourses($profile->id), 'myProfileForm' => $profileForm);
     }
 }
Ejemplo n.º 9
0
 /**
  * @param  object $identity
  * @return void
  */
 public function write($identity)
 {
     $metadataInfo = $this->options->getClassMetadata();
     $identifierValues = $metadataInfo->getIdentifierValues($identity);
     parent::write($identifierValues);
 }
Ejemplo n.º 10
0
 /**
  * Performs an authentication attempt
  *
  * @return \Zend\Authentication\Result
  * @throws \Zend\Authentication\Adapter\Exception\ExceptionInterface
  *                                                                   If authentication cannot be performed
  */
 public function authenticate()
 {
     /* Anti Injection de login */
     $login1 = Security\AntiInjection::antiSqlInjection1($this->getIdentity());
     $login2 = Security\AntiInjection::antiSqlInjection2($login1);
     $identity = Security\AntiInjection::antiSqlInjection3($login2);
     /* Anti Injection de senha */
     $senha1 = Security\AntiInjection::antiSqlInjection1($this->getCredential());
     $senha2 = Security\AntiInjection::antiSqlInjection2($senha1);
     $senha3 = Security\AntiInjection::antiSqlInjection3($senha2);
     /* Criptografa a senha */
     $crypt = new Security\Crypt();
     $credential = $crypt->encrypt($senha3);
     //Define os dados para processar o login
     $this->setIdentity($identity)->setCredential($credential);
     //Faz inner join dos dados do perfil no SELECT do Auth_Adapter
     $select = $this->getDbSelect();
     $select->where("ind_status = 'A'");
     //Efetua o login
     $result = parent::authenticate();
     //Verifica se o login foi efetuado com sucesso
     if ($result->isValid()) {
         //Recupera o objeto do usuário, sem a senha
         $info = $this->getResultRowObject($this->returnColumns, $this->credentialColumn);
         $storage = new SessionStorage();
         $storage->write($info);
         if ($result->getCode()) {
             return new ResultValidation(ResultValidation::SUCCESS, (array) $info);
         } else {
             return new ResultValidation(ResultValidation::FAILURE, null);
         }
     } else {
         return new ResultValidation(ResultValidation::FAILURE, null);
     }
 }
Ejemplo n.º 11
0
 /**
  * __construct
  * @todo Passing null SessionManager can have unintended consequences
  *
  * @param string         $namespace namespace
  * @param string         $member    member
  * @param SessionManager $manager   manager
  */
 public function __construct($namespace = 'RcmUser', $member = 'user', SessionManager $manager = null)
 {
     parent::__construct($namespace, $member, $manager);
 }
Ejemplo n.º 12
0
 /**
  * 验证登录
  * @param $platform
  * @return bool|mixed
  */
 protected function checkLogin($platform = self::FRONT_PLATFORM)
 {
     if ($platform == self::FRONT_PLATFORM) {
         /*$token = $this->postData['token'];
                     if (!empty($token)){
                         $tokenInfo = $this->tokenModel->select(array('token' => $token))->current();
                         if(!empty($tokenInfo)){
                             $this->memberInfo = $this->memberInfoModel->select(array('memberID' => $tokenInfo['memberID']))->current();
                         }
         
                     }*/
         $autoCode = $_COOKIE['autoCode'];
         if (!empty($autoCode)) {
             $this->memberInfo = $this->memberInfoModel->select(array('autoCode' => $autoCode))->current();
         } else {
             $loginSession = new Session($platform, null, null);
             $this->memberInfo = $session = $loginSession->read();
             if (!empty($this->memberInfo['memberID'])) {
                 $this->memberInfo = $this->memberInfoModel->select(array('memberID' => $this->memberInfo['memberID']))->current();
             }
         }
     } else {
         $loginSession = new Session($platform, null, null);
         $this->adminInfo = $session = $loginSession->read();
     }
     if (empty($this->memberInfo) && empty($this->adminInfo)) {
         return false;
     } else {
         return true;
     }
 }
Ejemplo n.º 13
0
 public function logoutAction()
 {
     $session = new Session(self::ADMIN_PLATFORM);
     $session->clear();
     return $this->redirect()->toUrl('/admin/index/login');
 }
Ejemplo n.º 14
0
 /**
  * Escreve os dados recebidos por parametro na sessao
  * 
  * @param string $contents        	
  */
 public function escreveSessao($contents)
 {
     $this->sessionStorage->write($contents, null);
 }
Ejemplo n.º 15
0
 public function logOutAction()
 {
     $session = new Session(self::FRONT_PLATFORM);
     $session->clear();
     setcookie('autoCode', '', time(), '/');
     return $this->redirect()->toUrl('/login/do-login');
 }
 public function loginAdminAction()
 {
     $authAdmin = new AuthenticationService();
     $authAdmin->setStorage(new SessionStorage("SessaoAdmin"));
     $authAdmin->clearIdentity();
     $authAdminLanguage = new AuthenticationService();
     $authAdminLanguage->setStorage(new SessionStorage("LanguageUserAdmin"));
     $authAdminLanguage->clearIdentity();
     $authReseller = new AuthenticationService();
     $authReseller->setStorage(new SessionStorage("SessaoReseller"));
     $authReseller->clearIdentity();
     $authResellerLanguage = new AuthenticationService();
     $authResellerLanguage->setStorage(new SessionStorage("LanguageUserReseller"));
     $authResellerLanguage->clearIdentity();
     // Recuperar parâmetros passados pela url
     $param = $this->params()->fromRoute('id', 0);
     /** @var \Application\Entity\WcUser $user */
     $user = $this->getEm()->getRepository("Application\\Entity\\WcUser")->find($param);
     if ($user) {
         $arraySession = $this->getArraySession($user);
         /** @var \Application\Service\ApplicationUserService $userLogged */
         $userLogged = $this->getServiceLocator()->get("Application\\Service\\ApplicationUserService");
         $userLogged->setUserLogged($arraySession);
         $sessionStorageLanguageUser = new SessionStorage("LanguageUser");
         $sessionStorageLanguageUser->write($user->getLanguage()->getAbbreviation(), NULL);
         $this->getServiceLocator()->get('Application\\Service\\ApplicationAccessLog')->save(['type' => 1, 'description' => 'Login Access - ' . $user->getFirstname() . ' ' . $user->getLastname()]);
     }
     return $this->redirect()->toRoute('home');
 }
 public function clear()
 {
     $this->getSessionManager()->getSaveHandler()->destroy($this->getSessionId());
     parent::clear();
 }
Ejemplo n.º 18
0
 /**
  * @param $newData
  */
 public function updateSessionData($newData)
 {
     $this->storage->write($newData);
 }
Ejemplo n.º 19
0
 public function regAction()
 {
     if (empty($this->postData)) {
         return $this->view;
     }
     $mobile = $this->postData['mobile'];
     $password = $this->postData['password'];
     //$confirmPassword = $this->postData['confirmPassword'];
     $nickName = $this->postData['nickName'];
     if (empty($mobile) || empty($password) || empty($nickName)) {
         return $this->response(ApiError::PARAMETER_MISSING, ApiError::PARAMETER_MISSING_MSG);
     }
     if (!$this->validateMobile($mobile)) {
         return $this->response(ApiError::MOBILE_VALIDATE_FAILED, ApiError::MOBILE_VALIDATE_FAILED_MSG);
     }
     if (strlen($password) < 6) {
         return $this->response(ApiError::PASSWORD_LT_SIX_WORDS, ApiError::PASSWORD_LT_SIX_WORDS_MSG);
     }
     if (mb_strlen($nickName, 'UTF-8') > 5) {
         return $this->response(ApiError::COMMON_ERROR, '昵称字数超过限制');
     }
     /*if($password != $confirmPassword){
           return $this->response(ApiError::TWICE_PASSWORD_NOT_SIMILAR, ApiError::TWICE_PASSWORD_NOT_SIMILAR_MSG);
       }*/
     $verifyCode = $this->mobileVerifyCodeModel->getLastVerifyCode($mobile);
     if ($verifyCode != $this->postData['verifyCode']) {
         return $this->response(ApiError::VERIFY_CODE_INVALID, ApiError::VERIFY_CODE_INVALID_MSG);
     }
     $where = array('nickName' => $nickName);
     $existMember = $this->memberInfoModel->select($where)->current();
     if (!empty($existMember)) {
         return $this->response(ApiError::MEMBER_EXIST_NICK_NAME, ApiError::MEMBER_EXIST_NICK_NAME_MSG);
     }
     $where = array('mobile' => $mobile);
     $existMember = $this->memberInfoModel->select($where)->current();
     if (!empty($existMember)) {
         return $this->response(ApiError::MEMBER_EXIST_MOBILE, ApiError::MEMBER_EXIST_MOBILE_MSG);
     }
     $data = array('mobile' => $mobile, 'password' => $this->memberModel->genPassword($password));
     $this->memberModel->insert($data);
     $memberID = $this->memberModel->getLastInsertValue();
     $memberInfoData = array('memberID' => $memberID, 'nickName' => $nickName, 'mobile' => $mobile);
     $this->memberInfoModel->insert($memberInfoData);
     $token = array('memberID' => $memberID, 'token' => uniqid());
     $this->tokenModel->insert($token);
     $memberInfo = array('token' => $token['token'], 'memberID' => $memberID, 'nickName' => $nickName);
     $loginSession = new Session(self::FRONT_PLATFORM, null, null);
     $loginSession->write($memberInfo);
     return $this->response(ApiSuccess::COMMON_SUCCESS, ApiSuccess::COMMON_SUCCESS_MSG, $memberInfo);
 }
Ejemplo n.º 20
0
 /**
  *
  */
 public function __construct($namespace = 'Msingi\\Cms\\Service\\AuthStorage')
 {
     parent::__construct($namespace);
 }
Ejemplo n.º 21
0
 public function __construct($namespace = 'auth', $member = null, SessionManager $manager = null)
 {
     parent::__construct($namespace, $member, $manager);
 }
Ejemplo n.º 22
0
 public function clear()
 {
     $this->session->getManager()->forgetMe();
     parent::clear();
 }