예제 #1
0
 public function execute()
 {
     try {
         if (request::getInstance()->isMethod('POST')) {
             $usuario = request::getInstance()->getPost('inputUser');
             $password = request::getInstance()->getPost('inputPassword');
             if (($objUsuario = usuarioTableClass::verifyUser($usuario, $password)) !== false) {
                 hook\security\securityHookClass::login($objUsuario);
                 if (request::getInstance()->hasPost('chkRememberMe') === true) {
                     $chkRememberMe = request::getInstance()->getPost('chkRememberMe');
                     $hash = md5($objUsuario[0]->id_usuario . $objUsuario[0]->usuario . date(config::getFormatTimestamp()));
                     $data = array(recordarMeTableClass::USUARIO_ID => $objUsuario[0]->id_usuario, recordarMeTableClass::HASH_COOKIE => $hash, recordarMeTableClass::IP_ADDRESS => request::getInstance()->getServer('REMOTE_ADDR'), recordarMeTableClass::CREATED_AT => date(config::getFormatTimestamp()));
                     recordarMeTableClass::insert($data);
                     setcookie(config::getCookieNameRememberMe(), $hash, time() + config::getCookieTime(), config::getCookiePath());
                 }
                 log::register('identificacion', 'NINGUNA');
                 hook\security\securityHookClass::redirectUrl();
             } else {
                 session::getInstance()->setError('Usuario y contraseña incorrectos');
                 routing::getInstance()->redirect(config::getDefaultModuleSecurity(), config::getDefaultActionSecurity());
             }
         } else {
             routing::getInstance()->redirect(config::getDefaultModule(), config::getDefaultAction());
         }
     } catch (PDOException $exc) {
         session::getInstance()->setFlash('exc', $exc);
         routing::getInstance()->forward('shfSecurity', 'exception');
     }
 }
예제 #2
0
 public function execute()
 {
     try {
         log::register('salida del sistema', 'NINGUNA', null, null, session::getInstance()->getUserId());
         session::getInstance()->setUserAuthenticate(false);
         session::getInstance()->setUserId(null);
         session::getInstance()->setUserName(null);
         session::getInstance()->deleteCredentials();
         if (request::getInstance()->hasCookie(config::getCookieNameRememberMe()) === true) {
             recordarMeTableClass::deleteSession(request::getInstance()->getCookie(config::getCookieNameRememberMe()), request::getInstance()->getServer('REMOTE_ADDR'));
             setcookie(config::getCookieNameRememberMe(), '', time() - config::getCookieTime(), config::getCookiePath());
         }
         routing::getInstance()->redirect(config::getDefaultModule(), config::getDefaultAction());
     } catch (PDOException $exc) {
         session::getInstance()->setFlash('exc', $exc);
         routing::getInstance()->forward('shfSecurity', 'exception');
     }
 }