/** * @return object | null */ public function getAuthData() { if (!$this->sessionContainer->offsetExists('data')) { return null; } return $this->sessionContainer->data; }
/** * @throws BadAuthenticationException */ public function authorize() { if (!$this->sessionContainer->offsetExists('data')) { throw new BadAuthenticationException('You must be first authenticated'); } $this->instagramWrapper->setAccessToken($this->sessionContainer->data); }
/** * Test if has datas with $uid key * @param mixed $uid * @return boolean */ public function has($uid) { if (null === $this->session) { return false; } return $this->session->offsetExists($uid); }
public function initAuth(MvcEvent $e) { $matches = $e->getRouteMatch(); $controller = $matches->getParam('controller'); $action = $matches->getParam('action'); $sesion = new Container('reminderSesion'); // ¿Es el controlador de errores? if ($controller === "Application\\Controller\\Error") { // No valida permisos return; } // No valida permisos if ($action == "error") { return; } // ¿es la página de Marketing? if ($controller === "Application\\Controller\\Index" && in_array($action, array('index'))) { // ¿Tiene una sesión activa ? if ($sesion->offsetExists('user_username')) { // Si se encuentra en la página de marketing y tiene una sesion activa // se lo envia de regreso a la página principal $matches->setParam("controller", "Application\\Controller\\Inicio"); $matches->setParam("action", "index"); // return; } else { // Si no tiene una sesion activa se lo deja permanecer en la página de marketing return; } } if ($controller === "Application\\Controller\\Admin" && in_array($action, array('colaborar'))) { return; } // ¿es el login o se está autenticando ? if ($controller === "Application\\Controller\\Login" && in_array($action, array('index', 'autenticar', 'logout'))) { if ($action == "logout") { return; } if ($sesion->offsetExists('user_username')) { // Si se encuentra en la página de marketing y tiene una sesion activa // se lo envia de regreso a la página principal $matches->setParam("controller", "Application\\Controller\\Inicio"); $matches->setParam("action", "index"); // return; } else { // Si no tiene una sesion activa se lo deja permanecer en la página de marketing return; } } // var_dump($sesion->offsetExists('user_username'));exit(); // Si no hay acl con esto se valida que inicie sesión if (!$sesion->offsetExists('user_username')) { $matches->setParam("controller", "Application\\Controller\\Login"); $matches->setParam("action", "index"); return; } }
public function getPickingStationByID($stationID) { $model = new PickingStationsModel($this->serviceLocator); $station = $model->getPickingStationByID($stationID); $session = new Container('warehouse'); $session->offsetSet('pickingStationID', $station[0]['ID']); $session->offsetSet('pickingStationName', $station[0]['StationName']); $session->offsetSet('pickingStationAlias', $station[0]['StationAlias']); if ($session->offsetExists('pickingStationID') && $session->offsetExists('pickingStationName') && $session->offsetExists('pickingStationAlias')) { return $station[0]; } else { return false; } }
public function loginAction() { // $crypt = new Cryptography\Service(); $form = new Login(); $request = $this->getRequest(); if ($request->isPost()) { //Validate the form $formValidator = new LoginValidator(); $form->setInputFilter($formValidator->getInputFilter()); $form->setData($request->getPost()); if ($form->isValid()) { $formData = $form->getData(); // $dbAdapter = $this->authService->getAdapter(); $authAdapter = $this->authService->getAdapter(); $authAdapter->setIdentity($formData['email_address']); $authAdapter->setCredential($formData['password']); // Perform the authentication query, saving the result $result = $this->authService->authenticate($authAdapter); if ($result->isValid()) { $data = $authAdapter->getResultRowObject(null, 'password'); $this->authService->getStorage()->write($data); $sessionContainer = new Container('base'); $redirectUrl = $sessionContainer->offsetExists('lastRequest') ? $sessionContainer->offsetGet('lastRequest') : 'home'; return $this->redirect()->toRoute($redirectUrl); } } $this->flashMessenger()->addErrorMessage('Validation failed'); } $viewModel = new ViewModel(array('form' => $form, 'errorMessages' => $this->flashMessenger()->getErrorMessages(), 'successMessages' => $this->flashMessenger()->getCurrentSuccessMessages())); // $viewModel->setTerminal(true-); //Remove this if you want your layout to be shown return $viewModel; }
public function onDispatch(MvcEvent $e) { /* $admin_session = new Container('admin'); $username = $admin_session->username; if(empty($username)) { return $this->redirect()->toRoute('adminlogin'); } */ /* Set Default layout for all the actions */ $this->layout('layout/layout'); $em = $this->getEntityManager(); $cities = $em->getRepository('\\Admin\\Entity\\City')->findBy(array('countryId' => 2)); $categories = $em->getRepository('\\Admin\\Entity\\Categories')->findBy(array('status' => 1)); $signupForm = new Forms\SignupForm(); $loginForm = new Forms\LoginForm(); $forgotpassForm = new Forms\ForgotPasswordForm(); $this->layout()->signupForm = $signupForm; $this->layout()->loginForm = $loginForm; $this->layout()->forgotpassForm = $forgotpassForm; $this->layout()->cities = $cities; $this->layout()->categories = $categories; $user_session = new Container('user'); $userid = $user_session->userId; $city = ""; $searchSession = new Container("searchsess"); $searchType = ""; $searchTerm = ""; if ($searchSession->offsetExists("type")) { $searchType = $searchSession->offsetGet("type"); $searchTerm = $searchSession->offsetGet("searchTerm"); } if ($searchType == "category" && $searchTerm != "") { $this->layout()->searchedCategory = $searchTerm; } if ($searchType == "city" && $searchTerm != "") { $this->layout()->userCity = $searchTerm; } if (!empty($userid)) { $msg = 'You are already logged in.'; $status = 1; $this->layout()->setVariable('userId', $user_session->userId); $this->layout()->setVariable('username', $user_session->userName); $username = $user_session->userName; $tmp_user = $em->getRepository('\\Admin\\Entity\\Users')->find($user_session->userId); $city = $tmp_user->getCity(); if ($searchType == "city" && $searchTerm != "") { $this->layout()->userCity = $searchTerm; } else { if (!empty($city)) { $cityObj = $em->getRepository('\\Admin\\Entity\\City')->find($city); $this->layout()->userCity = $cityObj->getCityName(); } } } else { $this->layout()->setVariable('userId', ''); } return parent::onDispatch($e); }
public function onBootstrap($e) { $e->getApplication()->getEventManager()->getSharedManager()->attach('Zend\\Mvc\\Controller\\AbstractActionController', 'dispatch', function ($e) { $controller = $e->getTarget(); $controllerClass = get_class($controller); $moduleNamespace = substr($controllerClass, 0, strpos($controllerClass, '\\')); $config = $e->getApplication()->getServiceManager()->get('config'); if (isset($config['module_layouts'][$moduleNamespace])) { $controller->layout($config['module_layouts'][$moduleNamespace]); } }, 100); $session = new Container('base'); if (!$session->offsetExists('language')) { if (substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) == "es") { $session->offsetSet('language', "es_ES"); } elseif (substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) == "en") { $session->offsetSet('language', "en_US"); } } $e->getApplication()->getServiceManager()->get('translator')->setLocale($session->offsetGet('language')); $e->getApplication()->getServiceManager()->get('translator'); $eventManager = $e->getApplication()->getEventManager(); $moduleRouteListener = new ModuleRouteListener(); $moduleRouteListener->attach($eventManager); }
/** * Before Dispatch Function * * @param MvcEvent $event */ function boforeDispatch(MvcEvent $event) { $sm = $event->getApplication()->getServiceManager(); $config = $sm->get('Config'); $list = $config['whitelist']; $name = $sm->get('request')->getUri()->getPath(); $controller = $event->getRouteMatch()->getParam('controller'); $action = $event->getRouteMatch()->getParam('action'); $session = new Container('User'); $controller = $event->getRouteMatch()->getParam('controller'); $action = $event->getRouteMatch()->getParam('action'); if (!(strpos($name, 'reset-password') || in_array($name, $list)) && $session->offsetExists('userId')) { $serviceManager = $event->getApplication()->getServiceManager(); $roleTable = $serviceManager->get('RoleTable'); $userRoleTable = $serviceManager->get('UserRoleTable'); $roleID = $userRoleTable->getUserRoles('user_id = ' . $session->offsetGet('userId'), array('role_id')); $roleName = $roleTable->getUserRoles('rid = ' . $roleID[0]['role_id'], array('role_name')); $userRole = $roleName[0]['role_name']; $acl = $serviceManager->get('Acl'); $acl->initAcl(); $status = $acl->isAccessAllowed($userRole, $controller, $action); if (!$status) { die('Permission denied'); } } }
/** * {@inheritDoc} */ public function getIdentityRoles() { $authService = $this->userService; // $definedRoles = $this->config['role_providers']['BjyAuthorize\Provider\Role\Config']['user']['children']; $roleKey = $this->config['ldap_role_key']; // $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); // $definedRoles = $em->getRepository("ZfcUserLdap\Entity\Role")->findAll(); // var_dump($role); // exit(); if (!$authService->getAuthService()->hasIdentity()) { return array($this->getDefaultRole()); } $session = new Container('ZfcUserLdap'); if (!$session->offsetExists('ldapObj')) { return array($this->getDefaultRole()); } // var_dump($roleKey); $user = $session->offsetGet('ldapObj'); $roles = array(); // var_dump($user); // var_dump($definedRoles); // exit(); foreach ($user->getRoles() as $role) { // if (isset($definedRoles[$role])) $roles[] = $role->getRoleId(); } return $roles; // $session = new Container('ZfcUserLdap'); // $user = $session->offsetGet('ldapObj'); // $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); // // $Roles = $em->getRepository("ZfcUserLdap\Entity\User")->find(); // // var_dump($authService->getAuthService()->getIdentity()); // var_dump($user); // exit(); }
/** * {@inheritDoc} */ public function offsetExists($key) { if (!empty($this->sessionVars[$key])) { return true; } return parent::offsetExists($key); }
function boforeDispatch(MvcEvent $event) { $request = $event->getRequest(); $response = $event->getResponse(); $target = $event->getTarget(); /* Offline pages not needed authentication */ $whiteList = array('Auth\\Controller\\Auth-login', 'Auth\\Controller\\Auth-logout', 'Auth\\Controller\\Auth-signup'); $requestUri = $request->getRequestUri(); $controller = $event->getRouteMatch()->getParam('controller'); $action = $event->getRouteMatch()->getParam('action'); $requestedResourse = $controller . "-" . $action; $session = new Container('User'); if ($session->offsetExists('email')) { if (in_array($requestedResourse, $whiteList)) { $url = '/TPWeb/public/produit'; $response->setHeaders($response->getHeaders()->addHeaderLine('Location', $url)); $response->setStatusCode(302); } } else { if (!in_array($requestedResourse, $whiteList)) { $url = '/TPWeb/public/auth'; $response->setHeaders($response->getHeaders()->addHeaderLine('Location', $url)); $response->setStatusCode(302); } $response->sendHeaders(); } //print "Called before any controller action called. Do any operation."; }
function boforeDispatch(MvcEvent $event) { $request = $event->getRequest(); $response = $event->getResponse(); $target = $event->getTarget(); $whiteList = array('Auth\\Controller\\Index-index', 'Auth\\Controller\\Index-logout'); $requestUri = $request->getRequestUri(); $controller = $event->getRouteMatch()->getParam('controller'); $action = $event->getRouteMatch()->getParam('action'); $requestedResourse = $controller . "-" . $action; $session = new Container('User'); if ($session->offsetExists('email')) { if ($requestedResourse == 'Auth\\Controller\\Index-index' || in_array($requestedResourse, $whiteList)) { $url = '/'; $response->setHeaders($response->getHeaders()->addHeaderLine('Location', $url)); $response->setStatusCode(302); } else { $serviceManager = $event->getApplication()->getServiceManager(); $userRole = $session->offsetGet('roleName'); $acl = $serviceManager->get('Acl'); $acl->initAcl(); $status = $acl->isAccessAllowed($userRole, $controller, $action); if (!$status) { die('Permission denied'); } } } else { if ($requestedResourse != 'Auth\\Controller\\Index-index' && !in_array($requestedResourse, $whiteList)) { $url = '/login'; $response->setHeaders($response->getHeaders()->addHeaderLine('Location', $url)); $response->setStatusCode(302); } $response->sendHeaders(); } }
function boforeDispatch(MvcEvent $event) { include 'config/constant.php'; $response = $event->getResponse(); $controller = $event->getRouteMatch()->getParam('controller'); $module_array = explode("\\", $controller); if ($module_array[0] == 'Admin') { $action = $event->getRouteMatch()->getParam('action'); $requestedResourse = $controller . "\\" . $action; $session = new Container('User'); if ($session->offsetExists('user')) { if (in_array($requestedResourse, $GLOBALS['PAGE_BEFORE_LOGIN'])) { $url = $GLOBALS['SITE_ADMIN_URL'] . 'dashboard/add'; $response->setHeaders($response->getHeaders()->addHeaderLine('Location', $url)); $response->setStatusCode(302); } } else { if ($requestedResourse != 'Admin\\Controller\\Index\\index' && !in_array($requestedResourse, $GLOBALS['PAGE_BEFORE_LOGIN'])) { $url = $GLOBALS['SITE_ADMIN_URL'] . 'index/login'; $response->setHeaders($response->getHeaders()->addHeaderLine('Location', $url)); $response->setStatusCode(302); } $response->sendHeaders(); } } }
public function testExchangeArrayObject() { $this->container->offsetSet('old', 'old'); $this->assertTrue($this->container->offsetExists('old')); $old = $this->container->exchangeArray(new \Zend\Stdlib\ArrayObject(array('new' => 'new'))); $this->assertArrayHasKey('old', $old, "'exchangeArray' doesn't return an array of old items"); $this->assertFalse($this->container->offsetExists('old'), "'exchangeArray' doesn't remove old items"); $this->assertTrue($this->container->offsetExists('new'), "'exchangeArray' doesn't add the new array items"); }
public function isExpiredAuthenticationTime() { $authSession = new Container(self::SESSION_CONTAINER_NAME); if ($authSession->offsetExists(self::SESSION_VARIABLE_NAME)) { $expirationTime = $authSession->offsetGet(self::SESSION_VARIABLE_NAME); return $expirationTime < time(); } return false; }
public function checkAuthentication($page_url) { $session = new Container('base'); if (!$session->offsetExists('logged_in') || $session->offsetGet('logged_in') !== true) { return $this->redirect()->toRoute('employee', array('action' => 'signin', 'controller' => 'employee')); } $session->setExpirationSeconds(28800); return true; }
/** * Gets a valid OAuth2.0 access token * * @param bool $forceNewToken * @return string */ public function getToken($forceNewToken = false) { if ($this->session->offsetExists('accessToken') && $this->session->offsetExists('expiryTime') && is_string($this->session->accessToken) && $this->session->expiryTime > time() && !$forceNewToken) { return $this->session->accessToken; } $code = $this->getCode(); if ($code instanceof Response) { return $code; } $httpClient = new HttpClient($this->options->vendorOptions->tokenEntryUri); $httpClient->setMethod('POST'); $params = array(); foreach ($this->options->stage2->toArray() as $key => $param) { if ($key === 'code') { $param = urlencode($code); } if (empty($param)) { $param = $this->getDefaultParam($key); } $params[$key] = $param; } $httpClient->setParameterPost($params); if (is_array($this->options->vendorOptions->headers)) { $httpClient->setHeaders($this->options->vendorOptions->headers); } $content = $httpClient->send()->getContent(); if ($this->options->vendorOptions->responseFormat === 'urlencode') { try { $response = Json\Decoder::decode($content); } catch (\Zend\Json\Exception\RuntimeException $e) { if ($e->getMessage() !== 'Illegal Token') { throw new OAuth2Exception('Error decoding Json: ' . $e->getMessage()); } parse_str($content, $response); } } else { $response = Json\Decoder::decode($httpClient->send()->getContent()); } if ($this->isInResponse($response, 'error')) { $error = $this->getFromResponse($response, 'error'); if (is_object($error) && method_exists($error, 'type') && method_exists($error, 'code') && method_exists($error, 'message')) { throw new OAuth2Exception("{$error->type} ({$error->code}): {$error->message}"); } else { if (!is_string($error)) { $error = Json\Encoder::encode($error); } throw new OAuth2Exception("Error returned from vendor: {$error}"); } } $expires = $this->getFromResponse($response, 'expiresIn'); $token = $this->getFromResponse($response, 'accessToken'); $this->session->expiryTime = $expires + time(); $this->session->accessToken = $token; return $token; }
public function index03Action() { $ssUser = new Container("user"); $ssUser->offsetUnset("name"); if ($ssUser->offsetExists("name")) { echo $ssUser->offsetGet("name"); } else { echo "Noooooooo session"; } return false; }
public function dbAction() { $sid = new Container('base'); $this->layout('layout/admin'); if ($sid->offsetExists('idSession')) { $idSession = $sid->offsetGet('idSession'); $this->dbAdapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter'); $tsession = new SessionTable($this->dbAdapter); $tsession->eliminarSesion($idSession); } return new ViewModel(); }
/** * Méthode d'initialisation des attributs Mongo. */ private function init() { $container = new Container('mongoUI'); if (!$container->offsetExists('connected')) { $this->redirect()->toUrl('/mongomyadmin/connection/index'); return false; } else { $this->mc = new MongoClient($container->mongoClient); $this->database = $container->database; return true; } }
/** * Do authorization * * @author Stoyan Rangelov * @param \Zend\Mvc\MvcEvent $event * @param \Zend\ServiceManager\ServiceManager $serviceManager * @return void */ public function doAuthorization($event, $serviceManager) { $permissionService = $serviceManager->get('permission.service'); $controller = $event->getRouteMatch()->getParam('controller'); $controllerClass = explode("\\", $controller); $namespace = isset($controllerClass[2]) ? $controllerClass[0] : 'API'; $controller = isset($controllerClass[2]) ? $controllerClass[2] : $controllerClass[0]; $request = $event->getRequest(); $neededResource = array('namespace' => $namespace, 'controller' => $controller, 'action' => $permissionService->getAction($request)); $permissionService->permissionExist($neededResource); if (!$permissionService->isAllowed($neededResource)) { $response = $event->getResponse(); $response->setStatusCode(403); $response->sendHeaders(); exit; } $session = new Container('base'); if ($session->offsetExists('company_id')) { $company_id = (int) $session->offsetGet('company_id'); } else { $company_id = null; } // if (!is_null($company_id)) { // if (!$permissionService->isAllowedByCompanyACL($neededResource, $company_id)) { // $response = $event->getResponse(); // $response->setStatusCode(403); // $response->sendHeaders(); // exit(); // } // } // // if ($event->getRouteMatch()->getParam('id')) { // $resource_id = $event->getRouteMatch()->getParam('id'); // $resource_type = strtolower($neededResource['controller']); // $entityClass = "$namespace\Entity\\$controller"; // // $resourceCompany = $permissionService->getCompanyByResource($entityClass, $resource_id, $resource_type); // if (!is_null($resourceCompany) && !is_null($company_id)) { // if ($company_id != $resourceCompany) { // $response = $event->getResponse(); // $response->setStatusCode(403); // $response->sendHeaders(); // exit(); // } // } // } }
public function onBootstrap(MvcEvent $e) { $eventManager = $e->getApplication()->getEventManager(); $locale = Locales::DEFAULT_LOCALE; $session = new Container('locale'); $translator = $e->getApplication()->getServiceManager()->get('mvctranslator')->getTranslator(); if ($session->offsetExists('locale')) { $locale = $session->locale; $translator->setLocale($locale); $translator->setFallbackLocale(Locales::DEFAULT_LOCALE); \Locale::setDefault($translator->getLocale()); } // Initialize doctrine event manager for translations. $this->initTranslations($e->getApplication()->getServiceManager()->get('doctrine.eventmanager.orm_default'), $locale); $moduleRouteListener = new ModuleRouteListener(); $moduleRouteListener->attach($eventManager); }
public function editAction() { $session = new Container('admin'); if (!$session->offsetExists('email')) { $this->redirect()->toRoute('admin', array('action' => 'login'), array('query' => array('status' => 'u_login'))); } $id = (int) $this->params()->fromRoute('id', 0); if (!$id) { return $this->redirect()->toRoute('product', array('action' => 'add')); } $request = $this->getRequest(); if ($request->isPost()) { /*---------------------------lles operation de la modification ----------------------------------*/ $name = strip_tags($this->getRequest()->getPost('name')); $desc = strip_tags($this->getRequest()->getPost('desc')); $ref = strip_tags($this->getRequest()->getPost('ref')); $prixm = strip_tags($this->getRequest()->getPost('prixm')); $prixy = strip_tags($this->getRequest()->getPost('prixy')); $dateb = strip_tags($this->getRequest()->getPost('dateb')); $datef = strip_tags($this->getRequest()->getPost('dateb')); $adapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter'); $sql = "update pro_product_bdma SET `product_bdma_name`='" . $name . "', `product_bdma_description`='" . $desc . "', `product_bdma_reference`='" . $ref . "', `product_bdma_price_month`='" . $prixm . "', `product_bdma_price_year`='" . $prixy . "', `product_bdma_date_begin_valid`='" . $dateb . "', `product_bdma_date_end_valid`='" . $datef . "' WHERE `id_product_bdma`='" . $id . "'"; $statement = $adapter->query($sql); $results = $statement->execute(); $this->redirect()->toRoute('product', array('action' => 'index'), array('query' => array('status' => 'yupdate'))); /*-----------------------------------------------------------------------------------------------*/ } /*------------------------------preparation des donnes-----------------------------*/ $adapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter'); $sql1 = "select * from pro_product_bdma where id_product_bdma='" . $id . "'"; $statement1 = $adapter->query($sql1); $results1 = $statement1->execute(); $row1 = $results1->current(); //tester si les variables rouX ont bien remplis if (!$row1) { //redirection vers l'index avec un message GET var $this->redirect()->toRoute('product', array('action' => 'index'), array('query' => array('status' => 'nouser'))); } /*---------------------------------------------------------------------------------*/ return new ViewModel(array('prod' => $row1)); }
public function deleteAction() { $session = new Container('admin'); if (!$session->offsetExists('email')) { $this->redirect()->toRoute('admin', array('action' => 'login'), array('query' => array('status' => 'u_login'))); } $id = (int) $this->params()->fromRoute('id', 0); if (!$id) { return $this->redirect()->toRoute('country'); } $request = $this->getRequest(); if ($request->isPost()) { $del = $request->getPost('del', 'Non'); if ($del == 'Oui') { $id = (int) $request->getPost('id'); $this->getCountryTable()->deleteCountry($id); } return $this->redirect()->toRoute('country'); } return array('id' => $id, 'country' => $this->getCountryTable()->getCountry($id)); }
public function indexAction() { $sid = new Container('base'); //$session->getManager()->getStorage()->clear(); if ($sid->offsetExists('usuario')) { return $this->redirect()->toUrl($this->getRequest()->getBaseUrl() . '/application'); } $id = (int) $this->params()->fromRoute('id', 0); $view = new ViewModel(); if ($id == 1) { $mensaje = "El usuario ingresado no se encuentra registrado en el sistema o la contraseña es incorrecta"; $view = new ViewModel(array('mensaje' => $mensaje)); } if ($id == 2) { $mensaje = "El usuario se encuentra desactivado"; $view = new ViewModel(array('mensaje' => $mensaje)); } if ($id == 3) { $mensaje = "Finalizó la sesión correctamente"; $view = new ViewModel(array('mensaje' => $mensaje)); } if ($id == 4) { $mensaje = "El usuario ya se encuentra en sesión en otro dispositivo, se alcanzó el limite permitido de sesión"; $view = new ViewModel(array('mensaje' => $mensaje)); } if ($id == 5) { $mensaje = "El usuario esta habilitado, pero no esta asociado algun condominio"; $view = new ViewModel(array('mensaje' => $mensaje)); } if ($id == 6) { $mensaje = "Error en el cambio de clave, favor intente nuevamente o contacte nuestro soporte Telefónico"; $view = new ViewModel(array('mensaje' => $mensaje)); } if ($id == 7) { $mensaje = "Permiso Denegado. Perfil no autorizado"; $view = new ViewModel(array('mensaje' => $mensaje)); } $this->layout('layout/login'); return $view; }
/** * Before Dispatch Function * * @param MvcEvent $event */ function boforeDispatch(MvcEvent $event) { $sm = $event->getApplication()->getServiceManager(); $config = $sm->get('Config'); $list = $config['whitelist']; $name = $sm->get('request')->getUri()->getPath(); $controller = $event->getRouteMatch()->getParam('controller'); $action = $event->getRouteMatch()->getParam('action'); $session = new Container('User'); // if (!$session->offsetExists('userId')) { // //return $this->redirect()->toRoute($config['BASE_URL_WEB']); // header('Location: '.$config['BASE_URL_WEB'].'/home'); // } $controller = $event->getRouteMatch()->getParam('controller'); $action = $event->getRouteMatch()->getParam('action'); if (!(strpos($name, 'reset-password') || in_array($name, $list)) && $session->offsetExists('userId')) { $serviceManager = $event->getApplication()->getServiceManager(); $roleTable = $serviceManager->get('RoleTable'); $userRoleTable = $serviceManager->get('UserRoleTable'); $roleID = $userRoleTable->getUserRoles('user_id = ' . $session->offsetGet('userId'), array('role_id')); if (empty($roleID)) { //Super //die('Permission Super'); } else { //Permision Nomals $roleName = $roleTable->getUserRoles('rid = ' . $roleID[0]['role_id'], array('role_name')); $userRole = $roleName[0]['role_name']; $acl = $serviceManager->get('Acl'); $acl->initAcl(); $status = $acl->isAccessAllowed($userRole, $controller, $action); if (!$status) { die('Permission denied'); } } // end if(empty($roleID)) } }
public function dmnAction() { $session = new Container('useradmin'); if (!$session->offsetExists('uid') && !$session->offsetExists('ucomp') && !$session->offsetGet('user') == 'user') { $this->redirect()->toRoute('useradmin', array('action' => 'loginuser'), array('query' => array('status' => 'u_login'))); } if (isset($_GET['iduser'])) { $id = $_GET['iduser']; $comp = $_GET['comp']; $adapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter'); $sql = "update pro_user set admin=1 where id='" . $id . "'"; $sql2 = "call fix_admin(" . $comp . ")"; $statement2 = $adapter->query($sql2); $statement = $adapter->query($sql); $results2 = $statement2->execute(); $results = $statement->execute(); $this->redirect()->toRoute('useradmin', array('action' => 'index'), array('query' => array('status' => 'ydmn'))); } else { $this->redirect()->toRoute('useradmin', array('action' => 'index'), array('query' => array('status' => 'n'))); } }
/** * Password Reset Confirmation Action * * @author Kaushal Kishore <*****@*****.**> * @package Users * @access Public * @return Object ViewModel */ public function passwordResetConfirmationAction() { $session = new Container('User'); $config = $this->getServiceLocator()->get('config'); // //Redirect to the home page if user login/// if ($session->offsetExists('userId')) { return $this->redirect()->toRoute($config['afterLoginURL']); } return new ViewModel(); }
/** * TODO: Update last update date password session */ public function updateLastUpdatePassword() { $sessionContainer = new SessionContainer(); $userDetails = $sessionContainer->offsetExists('userDetails'); return $userDetails; }