Example #1
0
 public function __construct(PdoSessionHandler $saveHandler, array $validators = [])
 {
     $config = new StandardConfig();
     $config->setOptions(['name' => 'mobicms', 'remember_me_seconds' => 1800, 'use_cookies' => true, 'cookie_httponly' => true]);
     $this->config = $config;
     $this->storage = new SessionArrayStorage();
     $this->saveHandler = $saveHandler;
     $this->validators = $validators;
 }
Example #2
0
 public function autenticarAction()
 {
     // si no hay POST se redirecciona al login
     if (!$this->request->isPost()) {
         return $this->redirect()->toRoute('login', array('controller' => 'login'));
     }
     $form = new LoginForm();
     $form->setInputFilter(new LoginFormValidator());
     // Obtenemos los datos desde el Formulario con POST data:
     $data = $this->request->getPost();
     $form->setData($data);
     // Validando el form
     if (!$form->isValid()) {
         $modelView = new ViewModel(array('form' => $form));
         $modelView->setTemplate('application/login/index');
         return $modelView;
     }
     $values = $form->getData();
     $username = $values['username'];
     $password = $values['password'];
     $remember = $values['remember'];
     try {
         $this->login->setMessage('El nombre de Usuario y Contraseña no coinciden.', LoginService::NOT_IDENTITY);
         $this->login->setMessage('La contraseña ingresada es incorrecta. Inténtelo de nuevo.', LoginService::INVALID_CREDENTIAL);
         $this->login->setMessage('Los campos de Usuario y Contraseña no pueden dejarse en blanco.', LoginService::INVALID_LOGIN);
         $this->login->login($username, $password);
         if ($remember == 1) {
             $arrayConf = array('name' => 'CoreAppSesion', 'cookie_lifetime' => 2419200, 'remember_me_seconds' => 2419200, 'use_cookies' => true, 'cookie_httponly' => true);
         } else {
             $arrayConf = array('remember_me_seconds' => 1800, 'name' => 'CoreAppSesion');
         }
         $config = new StandardConfig();
         $config->setOptions($arrayConf);
         $manager = new SessionManager($config);
         //guardamos las variables de sesion
         $sesion = new Container('CoreAppSesion');
         $sesion->user_username = $this->login->getIdentity()->usuarios_username;
         $sesion->user_user_id = $this->login->getIdentity()->usuarios_id;
         $sesion->user_rol_id = $this->login->getIdentity()->app_roles_id;
         $this->flashMessengerPlusControllerPlugin()->addSuccess('Login Correcto!', $this->login->message, false, null);
         //$this->logger->info("Login Correcto! Usuario: " . $username);
         $this->redirect()->toRoute('inicio');
     } catch (\Exception $e) {
         $this->flashMessengerPlusControllerPlugin()->addError('Login Incorrecto!', $e->getMessage(), false, null);
         //$this->logger->err($e->getMessage());
         return $this->redirect()->toRoute('login', array('controller' => 'login', 'action' => 'index'));
     }
 }
 /**
  * Metodo para validar acceso al portal
  * @return \Zend\View\Model\ViewModel
  */
 public function ingresoAction()
 {
     if ($this->getRequest()->isPost()) {
         $auth = new AuthenticationService();
         $validate = $this->getRequest()->getPost();
         $authAdapter = new AuthAdapter($this->adapter(), 'usuario', 'usuario_correo', 'usuario_password');
         $authAdapter->setIdentity($validate['correo']);
         $authAdapter->setCredential(md5($validate['password']));
         $resultado = $auth->authenticate($authAdapter);
         switch ($resultado->getCode()) {
             case Result::FAILURE_IDENTITY_NOT_FOUND:
                 $this->message = "Usuario y/o contraseña incorrectos";
                 $this->flashMessenger()->addMessage($this->message);
                 return $this->redirect()->toUrl($this->getRequest()->getBaseUrl() . '/login');
             case Result::FAILURE_CREDENTIAL_INVALID:
                 $this->message = "Usuario y/o contraseña incorrectos";
                 $this->flashMessenger()->addMessage($this->message);
                 return $this->redirect()->toUrl($this->getRequest()->getBaseUrl() . '/login');
             case Result::SUCCESS:
                 $this->flashMessenger()->clearMessages();
                 $store = $auth->getStorage();
                 $store->write($authAdapter->getResultRowObject(null, 'usuario_password'));
                 $sessionConfig = new StandardConfig();
                 $sessionConfig->setRememberMeSeconds(20)->setCookieLifetime(30)->setCookieSecure(true)->setGcMaxlifetime(60)->setGcDivisor(60);
                 $sesionMa = new SessionManager($sessionConfig);
                 $sesionMa->rememberMe(30);
                 $container = new Container('cbol');
                 $container->setExpirationSeconds(1800);
                 $sesionMa->start();
                 $container->idSession = $auth->getIdentity()->perfil_id;
                 $permisos = $this->getPermisos($auth->getIdentity()->usuario_id);
                 $container->permisosUser = $permisos;
                 $indexProfile = \Login\IndexAllProfile::listIndexAllProfiles($auth->getIdentity()->perfil_id);
                 if ($indexProfile == 'vias') {
                     $container->reportesVias = $this->getReportesViales();
                 }
                 if ($indexProfile == 'admin') {
                     $container->sugerencias = $this->getSugerenciasAction();
                 }
                 $container->setDefaultManager($sesionMa);
                 return $this->redirect()->toUrl($this->getRequest()->getBaseUrl() . "/{$indexProfile}");
             default:
                 echo 'Mensaje por defecto';
                 break;
         }
     }
 }
Example #4
0
 /**
  * Set entropy file /dev/urandom, see issue #3046
  *
  * @link https://github.com/zendframework/zf2/issues/3046
  */
 public function testSetEntropyDevUrandom()
 {
     if (!file_exists('/dev/urandom')) {
         $this->markTestSkipped("This test doesn't work because /dev/urandom file doesn't exist.");
     }
     $result = $this->config->setEntropyFile('/dev/urandom');
     $this->assertInstanceOf('Zend\\Session\\Config\\StandardConfig', $result);
 }
 public function getSessionManager()
 {
     $config = new StandardConfig();
     $config->setOptions(array('remember_me_seconds' => 1800, 'name' => 'tvp'));
     return new SessionManager($config);
 }
Example #6
0
 /**
  * Set session.save_path
  *
  * @param  string $savePath
  * @return SessionConfig
  * @throws Exception\InvalidArgumentException on invalid path
  */
 public function setSavePath($savePath)
 {
     if ($this->getOption('save_handler') == 'files') {
         parent::setSavePath($savePath);
     }
     $this->savePath = $savePath;
     $this->setOption('save_path', $savePath);
     return $this;
 }
Example #7
0
<?php

define('REDBEAN_MODEL_PREFIX', '../Model_');
require __DIR__ . '/../vendor/autoload.php';
require 'rb.php';
/*
require '../vendor/autoload.php';
$fvm = \RedBeanFVM\RedBeanFVM::getInstance();
gabordemooij\redbean\RedBeanPHP
*/
R::setup('mysql:host=localhost;dbname=smemailmf', 'root', '');
use Zend\Session\Config\StandardConfig;
use Zend\Session\SessionManager;
$config = new StandardConfig();
$config->setOptions(array('remember_me_seconds' => 1800000, 'name' => 'mailmf'));
$manager = new SessionManager($config);
//var_dump($manager);
use Zend\Session\Storage\ArrayStorage;
$populateStorage = array('foo' => 'bar');
$storage = new ArrayStorage($populateStorage);
$manager = new SessionManager();
$manager->setStorage($storage);
//var_dump($manager);
/*
$book = R::dispense("mail");
$book->author = "Santa Claus";
$book->title = "Secrets of Christmas";
$id = R::store( $book );
*/
Example #8
0
 /**
  * @dataProvider optionsProvider
  */
 public function testSetOptionsTranslatesUnderscoreSeparatedKeys($option, $getter, $value)
 {
     $options = array($option => $value);
     $this->config->setOptions($options);
     $this->assertSame($value, $this->config->{$getter}());
 }