Beispiel #1
0
 public function beforeFilter()
 {
     $this->Auth->allow('index', 'view', 'logout', 'login');
     Security::setHash('md5');
     /**
                 @ Set Value default For Layout Cpanal in Left Menu 
                 @ Alongkot
                 @ date 16 Nov 14
     */
     $this->set('homeMenu', '');
     $this->set('comicMenu', '');
     $this->set('SentMenu', '');
     $this->set('WaitMenu', '');
     $this->set('ApprveMenu', '');
     $this->set('infoMenu', '');
     $this->set('MygroupMenu', '');
     $this->set('userMenu', '');
     $this->set('companyMenu', '');
     $this->set('statMenu', '');
     $this->set('referer', $this->referer);
     $this->set('Auth', $this->Auth);
     $this->set('title_for_layout', '-:: ฐานข้อมูลการจัดการกากอุตสาหกรรม และสิ่งปฏิกูลฯ นิคมอุตสาหกรรมภาคเหนือ ::-');
     //Set admin layout for action that have admin
     if ($this->Auth->user('role') == 'admin') {
         $this->layout = 'cpanel';
     } else {
         if ($this->Auth->user('role') == 'user') {
             $this->layout = 'cpanel_user';
         }
     }
     /////// Custom message Error & Login Fail
     $this->Auth->authError = '<i class="fa fa-exclamation-triangle"></i> พื้นที่การในส่วนนี้ได้รับการป้องกันการเข้าถึงข้อมูล กรุณาเข้าสู่ระบบเพื่อใช้งาน...!!!';
 }
Beispiel #2
0
 function beforeFilter()
 {
     //$this->Auth->allow('*');
     $this->Auth->authorize = 'controller';
     $this->Auth->logoutRedirect = '/';
     Security::setHash('md5');
     $this->set('Auth', $this->Auth->user());
     if ($this->Auth->user('tipo') == 'consultor') {
         $this->Session->write('Empresa.id', $this->Auth->user('empresa_id'));
     }
     if (!$this->Session->check('mes')) {
         $this->Session->write('mes', date('m'));
     }
     if (!$this->Session->check('ano')) {
         $this->Session->write('ano', date('Y'));
     }
     if (!$this->Session->check('fecha')) {
         $this->Session->write('fecha', date('Y') . '-' . date('m') . '-00');
     }
     if ($this->Session->check('Empresa.id')) {
         $empr = $this->Empresa->find('first', array('conditions' => array('Empresa.id' => $this->Session->read('Empresa.id')), 'recursive' => 0));
         $this->Session->write('Empresa.nombre', $empr['Empresa']['nombre']);
         $this->Session->write('Empresa.seguridad_id', $empr['Empresa']['seguridad_id']);
     }
 }
 function beforeFilter()
 {
     //$this->Auth->allow('index','view');
     $this->Auth->allow('index', 'view');
     //$this->Auth->allow('login','save');
     Security::setHash('md5');
 }
Beispiel #4
0
 public function beforeFilter()
 {
     Security::setHash('md5');
     if (!isset($this->params['admin']) || !$this->params['admin']) {
         $this->Auth->allow();
     }
 }
 function beforeFilter()
 {
     Security::setHash('sha256');
     $this->Auth->userModel = 'Account';
     $this->Auth->fields = array('username' => 'login', 'password' => 'hashed_password');
     $this->Auth->allowedActions = array('register');
     $this->Auth->LoginRedirect = array('controller' => 'account', 'action' => 'view');
 }
Beispiel #6
0
 function beforeFilter()
 {
     Security::setHash('sha1');
     $this->Auth->userModel = 'Volunteers';
     $this->Auth->fields = array('username' => 'email', 'password' => 'password');
     // Allow everything...for now
     $this->Auth->allow('*');
 }
Beispiel #7
0
 /**
  * beforeFilter function called before filter
  *
  * @access public
  * @return void
  */
 public function beforeFilter()
 {
     $timezone = $this->SysParameter->findByParameterCode('system.timezone');
     // default to UTC if no timezone is set
     if (!(empty($timezone) || empty($timezone['SysParameter']['parameter_value']))) {
         $timezone = $timezone['SysParameter']['parameter_value'];
         // check that the timezone is valid
         if (isset($this->validTZ[$timezone])) {
             date_default_timezone_set($timezone);
         } else {
             $this->Session->setFlash(__('An invalid timezone is provided, please edit "system.timezone"', true));
         }
     }
     $this->Auth->autoRedirect = false;
     // backward compatible with original ipeer hash  method
     Security::setHash('md5');
     Configure::write('Security.salt', '');
     $locale = $this->SysParameter->findByParameterCode('display.locale');
     // default to eng if no locale is set
     if (!(empty($locale) || empty($locale['SysParameter']['parameter_value']))) {
         $locale = $locale['SysParameter']['parameter_value'];
         // TODO: check that the locale is valid
         Configure::write('Config.language', $locale);
     } else {
         Configure::write('Config.language', 'eng');
     }
     // if we have a session transfered to us
     if ($this->_hasSessionTransferData()) {
         if ($this->_authenticateWithSessionTransferData()) {
             if (method_exists($this, '_afterLogin')) {
                 $this->_afterLogin(false);
             }
         } else {
             $this->Session->setFlash($this->Auth->loginError, $this->Auth->flashElement, array(), 'auth');
         }
     }
     // store user in the singleton for global access
     User::store($this->Auth->user());
     $this->breadcrumb = Breadcrumb::create();
     if ($this->Auth->isAuthorized()) {
         // check if the user has permission to access the controller/action
         $permission = array_filter(array('controllers', ucwords($this->params['plugin']), ucwords($this->params['controller']), $this->params['action']));
         if (!User::hasPermission(join('/', $permission))) {
             $this->Session->setFlash('Error: You do not have permission to access the page.');
             $this->redirect('/home');
             return;
         }
         $this->_checkSystemVersion();
     }
     // for setting up google analytics
     $trackingId = $this->SysParameter->findByParameterCode('google_analytics.tracking_id');
     $domain = $this->SysParameter->findByParameterCode('google_analytics.domain');
     $customLogo = $this->SysParameter->findByParameterCode('banner.custom_logo');
     $this->set('trackingId', $trackingId);
     $this->set('domain', $domain);
     $this->set('customLogo', $customLogo);
     parent::beforeFilter();
 }
 function beforeFilter()
 {
     Security::setHash('md5');
     //$this->Auth->loginRedirect = array('admin' => 1, 'controller' => 'contacts', 'action' => 'index');
     $this->Auth->loginRedirect = array('controller' => 'courses', 'action' => 'index');
     // $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login', 'admin' => false);
     $this->Auth->loginAction = 'http://myfluentstats.com/Account/Login?ReturnUrl=%2f';
     $this->Auth->autoRedirect = false;
     $this->Auth->allow('display', 'contactus', 'form', 'checkout', 'reset');
     if (isset($this->params['admin']) && $this->params['admin'] == 1) {
         $this->layout = "admin";
     }
     $this->Auth->fields = array('username' => 'email', 'password' => 'password');
     //$curuser = $this->Auth->user();
     $auth = Configure::read('auth');
     if (empty($auth)) {
         $curuser = $this->Auth->user();
     }
     if ($curuser && !empty($curuser)) {
         if ($curuser['User']['group_id'] == 2) {
             $company = $this->User->Company->find('first', array('conditions' => array('Company.user_id' => $curuser['User']['id'])));
             $curuser['Company'] = $company['Company'];
             $this->set('custom_logo', $curuser['Company']['logo']);
         } elseif ($curuser['User']['group_id'] == 3) {
             $this->User->Contact->recursive = 1;
             $contact = $this->User->Contact->find('all', array('conditions' => array('Contact.user_id' => $curuser['User']['id'])));
             $curuser['Contact'] = $contact['0']['Contact'];
             $curuser['Genre'] = $contact['0']['Genre'];
             $this->set('custom_logo', $this->User->Company->field("logo", array("Company.id" => $curuser['Contact']['company_id'])));
         }
     }
     $this->set('loggedInUser', $curuser);
     $this->curuser = $curuser;
     /*
     if ($curuser && $val = $this->__checkUserAccess($curuser)) {
     	//$this->Auth->allow('*');
     	$this->Auth->allow($this->params['controller']);
     	$this->Session->setFlash('Allow: ' . $val . ' <pre>' . print_r($this->params, true) . '</pre>');
     }
     else {
     	//$this->Auth->deny('*');
     	$this->Auth->deny($this->params['controller']);
     	$this->Session->setFlash('Deny: ' . $this->params['controller'] . '<pre>' . print_r($this->params, true) . '
     		' . print_r($curuser, true) . '</pre>');
     }
     */
     if ($curuser && !$this->__checkUserAccess($curuser)) {
         //$this->Auth->deny('*');
         //$this->Auth->deny($this->params['action']);
         echo 'hey why are you not working';
         $this->Session->setFlash('Weird<pre>' . print_r($curuser, true) . '</pre>');
         //exit();
         //$this->Session->setFlash('You do not have access to that page.' . $this->params['controller'] . ' : ' . $this->params['action']);
         //$this->redirect($this->Auth->logout());
     }
     $this->siteDown = false;
 }
Beispiel #9
0
 public function beforeFilter()
 {
     if (!$this->ControleDeAcesso->validaAcessoAcao()) {
         //$this->Session->setFlash('<strong>Atenção!</strong> Você não tem permissão para acessar esta página.', 'danger');
         //$this->redirect(array('controller'=>'principal','action'=>'index'));
     }
     AuthComponent::$sessionKey = "Auth.Indicadores";
     Security::setHash('md5');
 }
 /**
  * Overwrite check login and set layout -> Check layout view unlogin and login
  *
  * @author ThanhN
  * @date 2016/05/21
  */
 function beforeFilter()
 {
     Security::setHash("md5");
     //echo Security::hash('admin',NULL,TRUE);
     $this->Auth->allow(array('login', 'logout'));
     $this->settingAuth();
     parent::beforeFilter();
     $this->set('authUser', $this->Auth->user());
 }
Beispiel #11
0
 function beforeFilter()
 {
     Security::setHash("md5");
     $this->authUser = $this->Auth->user();
     if (!empty($this->authUser)) {
         $this->userId = $this->authUser['User']['id'];
     } else {
         $this->userId = null;
     }
 }
 public function beforeFilter()
 {
     parent::beforeFilter();
     /*
      * Hack for Security component to work for AJAX. Normally, CSRF is enabled by
      * default and you need to supply a white list. Instead, I pass just the
      * action that is being called in the moment, white listing everything
      */
     $this->Security->unlockedActions = [$this->request->params['action']];
     Security::setHash($this->hashType);
 }
Beispiel #13
0
 function beforeFilter()
 {
     Security::setHash('sha256');
     // Configure AuthComponent
     $this->Auth->authorize = 'actions';
     $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
     // The action to login
     $this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login');
     // Where we redirect after logout
     $this->Auth->loginRedirect = array('controller' => 'patients', 'action' => 'search');
     // Where we redirect after login
 }
 function beforeFilter()
 {
     // Handle the user auth filter
     // This, along with no salt in the config file allows for straight
     // md5 passwords to be used in the user model
     Security::setHash("md5");
     $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
     $this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'myprofile');
     $this->Auth->logoutRedirect = '/';
     $this->Auth->loginError = 'Invalid username / password combination. Please try again';
     $this->Auth->authorize = 'controller';
     $this->set('usuario', $this->Auth->user());
 }
Beispiel #15
0
 function beforeFilter()
 {
     $this->Auth->authorize = 'Controller';
     $user_id = $this->Auth->user('id');
     $role = $this->Auth->user('role');
     $rol = $this->Auth->user('Rol.id');
     Security::setHash('md5');
     $this->Auth->allow('*');
     $username = $this->Auth->user('username');
     if (!empty($user_id)) {
         //	echo $user_id;
         $useraux = $this->User->find('first', array('conditions' => array('User.id' => $user_id)));
         $catalogo1 = $useraux['User']['catalogo_id1'];
         $catalogo2 = $useraux['User']['catalogo_id2'];
         $catalogo3 = $useraux['User']['catalogo_id3'];
         $catalogo4 = $useraux['User']['catalogo_id4'];
         $modulos = $this->ModulosRol->find('all', array('conditions' => array('ModulosRol.rol_id' => $rol, 'Modulo.modulo_id' => 0, 'Modulo.activo' => 1), 'order' => array('Modulo.orden')));
         foreach ($modulos as $m) {
             $modulos_id[] = $m['Modulo']['id'];
         }
         if (!empty($modulos_id)) {
             $submodulos = $this->ModulosRol->find('all', array('conditions' => array('ModulosRol.rol_id' => $rol, 'Modulo.modulo_id' => $modulos_id, 'Modulo.activo' => 1)));
             foreach ($submodulos as $s) {
                 $submodulos_id[] = $s['Modulo']['id'];
             }
         }
     }
     $contacto = $this->Contenido->find('first', array('conditions' => array('alias' => 'contacto')));
     // se tiene que tener un contenido con alias contacto a juro para que desde el home se pueda
     // hacer link a contacto desde el botón contáctanos
     $config = $this->Config->find('first');
     // hacemos el menu
     $menu_principal = $this->Modulo->find('all', array('conditions' => array('modulo_id' => 0), 'recursive' => -1, 'order' => array('Modulo.orden')));
     foreach ($menu_principal as $m) {
         $sub_modulos = $this->Modulo->find('all', array('conditions' => array('modulo_id' => $m['Modulo']['id']), 'recursive' => -1, 'order' => array('Modulo.orden')));
         $m['Modulo']['Submodulo'] = $sub_modulos;
         $menu[] = $m;
     }
     $catalogos = $this->Catalogo->find('all', array('order' => array('Catalogo.id')));
     foreach ($catalogos as $cc) {
         $misc[$cc['Catalogo']['id']] = $cc['Catalogo']['descripcion'];
     }
     // termina el menu
     // numerito de pedidos
     $cliente_id = $this->Auth->user('cliente_id');
     $pedidos_pendientes = $this->Pedido->find('all', array('conditions' => array('cliente_id' => $cliente_id, 'status !=' => array('Despachado', 'Cancelado'))));
     $pedidos_despachado = $this->Pedido->find('all', array('conditions' => array('cliente_id' => $cliente_id, 'status' => array('Despachado'))));
     $this->set(compact('username', 'user_id', 'rol', 'modulos', 'submodulos', 'modulos_id', 'submodulos_id', 'contacto', 'config', 'menu', 'pedidos_pendientes', 'pedidos_despachado', 'catalogo1', 'catalogo2', 'catalogo3', 'catalogo4', 'misc'));
 }
Beispiel #16
0
 function beforeFilter()
 {
     parent::beforeFilter();
     Security::setHash("md5");
     $this->Auth->userModel = 'User';
     $this->Auth->authorize = 'controller';
     $this->Auth->fields = array('username' => 'username', 'password' => 'password');
     //$this->Auth->loginAction = array('controller'=>'users','action'=>'index'); //action se chuyen toi sau khi access trang we
     //$this->Auth->loginRedirect = array('controller'=>'users','action'=>'profile');//action se chuyen den sau khi logi
     $this->Auth->logoutRedirect = array('admin' => false, 'controller' => 'users', 'action' => 'index');
     $this->Auth->loginError = 'Failed to login';
     //thong bao dang nhap bi lo
     $this->Auth->authError = 'Access denied';
     //thong bao truy cap khong dung khu vuc
     $this->Auth->allow(array('index', 'register', "CheckUser"));
 }
Beispiel #17
0
 function beforeFilter()
 {
     Security::setHash("md5");
     $this->Auth->userModel = 'User';
     $this->Auth->fields = array('username' => 'username', 'password' => 'password');
     $this->Auth->loginAction = array('admin' => false, 'controller' => 'user', 'action' => 'login');
     $this->Auth->loginRedirect = array('admin' => true, 'controller' => 'user', 'action' => 'index');
     $this->Auth->loginError = 'Username / password combination.  Please try again';
     $this->Auth->authorize = 'controller';
     //action allow not login
     $this->Auth->allow('login', 'admin_add');
     $this->set("admin", $this->_isAdmin());
     $this->set("logged_in", $this->_isLogin());
     $this->set("users_userid", $this->_usersUserID());
     $this->set("users_username", $this->_usersUsername());
 }
Beispiel #18
0
 /**
  * undocumented function
  *
  * @return void
  * @access public
  */
 function beforeFilter()
 {
     Security::setHash('md5');
     $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
     $this->Auth->logoutRedirect = '/';
     $this->Auth->loginError = 'Wrong username / password combination';
     $this->Auth->authError = 'You must be logged in before you try to do that';
     $this->Auth->authorize = 'controller';
     $this->Auth->autoRedirect = false;
     $cookie = $this->Cookie->read('User');
     if (is_array($cookie) && !$this->Auth->user()) {
         if ($this->User->checkLogin($cookie['username'], $cookie['token'])) {
             if (!$this->Auth->login($this->User)) {
                 $this->Cookie->del('User');
             }
         }
     }
 }
 function userverify()
 {
     $this->autoRender = false;
     $user_id = $_POST['user'];
     $pass = $_POST['pass'];
     if (empty($user_id)) {
         die(json_encode(array("error" => "1", "Message" => "User not provided.")));
     }
     if (empty($pass)) {
         die(json_encode(array("error" => "3", "Message" => "Password not provided.")));
     }
     $this->loadModel('User');
     $user = $this->User->find('first', array('conditions' => array('email' => $user_id), 'contain' => array()));
     if (empty($user)) {
         die(json_encode(array("error" => "2", "Message" => "User not found.")));
     }
     Security::setHash('md5');
     echo $user['User']['password'] == Security::hash($pass, null, true) ? 'true' : 'false';
 }
Beispiel #20
0
 function beforeFilter()
 {
     parent::beforeFilter();
     Security::setHash('md5');
     //$this->Session->destroy();
     if ($this->params['prefix'] == 'admin') {
         $referer = $this->referer(null, true);
         if (empty($referer)) {
             $referer = array('controller' => 'dashboard', 'action' => 'index', 'admin' => 'true');
         }
         $this->Auth->allow('admin_login');
         $this->Auth->fields = array('username' => 'u_name', 'password' => 'powd');
         //$this->Auth->userScope = array('User.is_active' => '1','User.is_deleted' => '0','User.user_type' => '0');
         $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login', 'admin' => true);
         $this->Auth->loginRedirect = $referer;
         //$this->Auth->logoutRedirect = array('controller'=>'users','action'=>'login','admin'=> true);
     } else {
     }
 }
Beispiel #21
0
 /**
  * Setup the authentication component.
  */
 private function setupAuth()
 {
     Security::setHash(Configure::read('Security.hash'));
     $this->Auth->authenticate = array('Form' => array('scope' => array('User.is_active' => 1), 'fields' => array('username' => 'email', 'password' => 'password')));
     $this->Auth->loginAction = '/login';
     $this->Auth->loginRedirect = '/dashboard';
     $this->Auth->logoutRedirect = '/';
     $this->Auth->authError = 'You must sign in to continue.';
     $this->Auth->flash = array('element' => 'notification/error', 'key' => 'auth', 'params' => array());
     $this->Auth->fields = array('username' => 'email', 'password' => 'password');
     if ($this->isMobile()) {
         $this->Auth->loginRedirect = '/containers';
     }
     if ($this->_secure) {
         $this->Auth->deny();
     } else {
         $this->Auth->allow();
     }
 }
Beispiel #22
0
 function beforeFilter()
 {
     // url para usar en la carga de imagenes
     //$this->Session->write('urlbase','http://maties.es');
     // Handle the user auth filter
     // This, along with no salt in the config file allows for straight
     // md5 passwords to be used in the user model
     Security::setHash("md5");
     $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
     $this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'datos');
     $this->Auth->logoutRedirect = '/';
     $this->Auth->loginError = 'Error usuario / password. Por favor, intentel de nuevo';
     $this->Auth->authError = "Para poder acceder necesitas identificarte";
     $this->Auth->authorize = 'controller';
     $this->set('usuario', $this->Auth->user());
     $this->RequestHandler->setContent('json', 'text/x-json');
     if ($this->RequestHandler->isAjax()) {
         $this->layout = 'ajax';
     }
 }
Beispiel #23
0
 function beforeFilter()
 {
     //Sitewide Configurations
     ClassRegistry::init('Configuration');
     $this->Configuration = new Configuration();
     $configs = $this->Configuration->find('all', array('fields' => array('name', 'value')));
     foreach ($configs as $config) {
         Configure::write($config['Configuration']['name'], $config['Configuration']['value']);
     }
     //Use MD5 hashing
     Security::setHash('md5');
     //Authenticate
     $this->Auth->allow('*');
     $this->Auth->loginAction = array('controller' => 'customers', 'action' => 'login');
     $this->Auth->loginRedirect = '/';
     $this->Auth->loginError = 'No username and password was found with that combination.';
     $this->Auth->logoutRedirect = '/';
     $this->Auth->userModel = 'Customer';
     $this->Auth->fields = array('username' => 'email', 'password' => 'password');
 }
Beispiel #24
0
 function beforeFilter()
 {
     if (ENABLE_USERS == 1) {
         Security::setHash('md5');
         // Authenticate
         $this->Auth->deny();
         $this->Auth->allow('display');
         // Allow static pages to be rendered for not authenticated users
         $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
         $this->Auth->loginRedirect = array('controller' => 'vehicles', 'action' => 'index');
         $this->Auth->logoutRedirect = array('controller' => 'pages', 'action' => 'home');
         $this->Auth->authError = 'Παρακαλώ δώστε τα στοιχεία σας ...';
         $this->Auth->loginError = 'Λάθος συνδυσμός ονόματος χρήστη / κωδικού πρόσβασης.';
         if ($this->Auth->user()) {
             $this->set("username", $this->Auth->user('username'));
             $this->Session->write('user', $this->Auth->user('username'));
         }
     } else {
         $this->Auth->allow();
     }
 }
Beispiel #25
0
 public function beforeFilter()
 {
     $this->setDefaultCookies();
     //handling the default language
     //$this->initlanguage();
     //debug for ajax
     if (isset($this->request->params['named']['ajax'])) {
         $this->layout = null;
         Configure::write('debug', Configure::read('ajaxDebug'));
     }
     $this->Auth->allow('changeLanguage');
     //using blowfish algoritm
     Security::setHash('blowfish');
     //check login session
     if ($this->Auth->loggedIn()) {
         $this->logged = $this->Auth->user();
     }
     $this->set('logged', $this->logged);
     if (!empty($this->logged)) {
         $this->set('menuItems', $this->Menu->getMenu($this->logged['group_id']));
     }
 }
Beispiel #26
0
 function beforeFilter()
 {
     Configure::write('Config.language', $this->Session->read('Config.language'));
     setlocale(LC_ALL, 'ptb');
     // var_dump(Configure::read('Config.language'));
     // for index actions
     /*
             if($this->action == 'index') {  
                 //setup filter component  
                 $this->_Filter = $this->Filter->process($this);  
                 $url = $this->Filter->url;  
                 if(empty($url)) {  
                     $url = '/';  
                 }  
                 $this->set('filter_options',array('url'=>array($url)));  
                 // setup default datetime filter option  
                 $this->_Form_options_datetime = array('type'=>'date','dateFormat'=>'DMY','empty'=>'-','minYear'=>date("Y")-2,'maxYear'=>date("Y"));  
                 // reset filters  
                 if(isset($this->data['reset']) || isset($this->data['cancel'])) {  
                     $this->redirect(array('action'=>'index'));  
                 }  
             } 
     */
     //Configure AuthComponent
     Security::setHash('md5');
     //$this->Auth->allow('*');
     //$this->Auth->authorize = 'actions';
     $this->Auth->authorize = array('Actions' => array('actionPath' => 'controllers'));
     $this->Auth->autoRedirect = false;
     $this->Auth->loginError = "Nome de Usuário ou senha incorrectas";
     $this->Auth->authError = "Não possui permissão para aceder ao sistema";
     $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
     $this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login');
     $this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'after_login');
     //$this->Auth->actionPath = 'Controllers';
     //var_dump($this->Auth->isAuthorized($this->Auth->user(),'Funcionarios/index'));
     //$this->Acl->allow(array('model'=>'User','foreign_key'=>'1'),'controllers/Funcionarios/index','*');
     //var_dump($this->Acl->check(array('model'=>'User','foreign_key'=>'1'),'controllers/Funcionarios/index','read'));
 }
Beispiel #27
0
 function beforeFilter()
 {
     Security::setHash('md5');
     $this->Auth->fields = array('username' => 'email', 'password' => 'password');
     $this->Auth->loginError = 'Please login below';
     $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
     $this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'profile');
     $this->Auth->authorize = 'controller';
     $this->Auth->userScope = array('User.active' => '1');
     $this->set('logged_in_user', $this->Auth->user());
     if ($this->RequestHandler->isAjax()) {
         Configure::write('debug', 0);
         //  these came along with the code block we found... might want to use them later?
         //$this->RequestHandler->setContent('javascript', 'text/javascript');
         //$this->RequestHandler->respondAs('javascript');
         $this->layout = 'ajax';
     }
     // if admin pages are being requested
     if (isset($this->params['admin'])) {
         // check the admin is logged in
         // this method is in the app_controller.php file
         $this->checkAdminSession();
     }
     if ($this->action != 'edit_password' && $this->action != 'logout' && $this->checkResetPassword()) {
         if ($this->action != 'logout') {
             $this->redirect('/users/edit_password');
         }
     }
     // force some actions to ssl
     if (in_array($this->params['action'], $this->ssl_required_actions)) {
         $this->Ssl->force();
     } else {
         $this->Ssl->unforce();
     }
     $this->setMetas();
     //check facebook logged in status
     $fbid = $this->facebook->get_loggedin_user();
     $this->set('fbid', $fbid);
 }
Beispiel #28
0
 /**
  * Before filter method acts first in the controller
  *
  * Configures the auth component to use the email column as the user name
  */
 public function beforeFilter()
 {
     parent::beforeFilter();
     $this->Auth->userModel = 'User';
     //Customise the login error
     $this->Auth->loginError = 'The credentials you entered were incorrect. Please try again or have you <a href="lost_password">lost your password</a>';
     //Customise thge auth error (when they try to access a protected part of the site)
     $this->Auth->authError = 'You need to login to view that page';
     //Use sha256 as the hashing algorithm for the site as it is the most secure out of the allowed options.
     Security::setHash('sha256');
     if ($this->Auth->loggedIn()) {
         $user_id = $this->Auth->user('id');
         $user_name = $this->Auth->user('name');
         $user_email = $this->Auth->user('email');
         $this->{$this->modelClass}->setCurrentUserData($user_id, $user_name, $user_email);
         $this->set('user_id', $user_id);
         $this->set('user_name', $user_name);
         $this->set('user_email', $user_email);
     }
     // Load config file in
     $this->devtrack_config = array_merge(Configure::read('devtrack'), ClassRegistry::init('Settings')->find('list', array('fields' => array('Settings.name', 'Settings.value'))));
     $this->set('devtrack_config', $this->devtrack_config);
     // if admin pages are being requested
     if (isset($this->params['admin'])) {
         // check the admin is logged in
         if ($this->Auth->user('is_admin') == 0) {
             $this->redirect('/');
         }
     }
     if (isset($this->params['api'])) {
         // The following line kinda breaks the M->V->C thing
         $this->{$this->modelClass}->_is_api = true;
     }
     if ($theme = $this->Auth->user('theme')) {
         $this->set('user_theme', $theme);
     } else {
         $this->set('user_theme', null);
     }
 }
Beispiel #29
0
 /**
  * Execution method always used for tasks
  *
  * @return void
  */
 public function execute()
 {
     Security::setHash('sha512');
     $file = Hash::get($this->args, '0');
     if (!file_exists($file)) {
         $this->out(__d('users', '<warning>Not found file.</warning>'));
         return;
     }
     $user = $this->User->findById(1);
     CakeSession::write(AuthComponent::$sessionKey, $user['User']);
     $request = new CakeRequest();
     $controller = new Controller($request);
     Current::initialize($controller);
     if (!$this->User->importUsers($file)) {
         //バリデーションエラーの場合
         //$this->NetCommons->handleValidationError($this->User->validationErrors);
         $this->out(__d('users', '<error>Import error.</error>'));
         $this->out(var_export($this->User->validationErrors, true));
     } else {
         $this->out(__d('users', '<success>Import success.</success>'));
     }
 }
 /**
  * testHash method
  *
  * @access public
  * @return void
  */
 function testHash()
 {
     $Security = Security::getInstance();
     $_hashType = $Security->hashType;
     $key = 'someKey';
     $hash = 'someHash';
     $this->assertIdentical(strlen(Security::hash($key, null, false)), 40);
     $this->assertIdentical(strlen(Security::hash($key, 'sha1', false)), 40);
     $this->assertIdentical(strlen(Security::hash($key, null, true)), 40);
     $this->assertIdentical(strlen(Security::hash($key, 'sha1', true)), 40);
     $result = Security::hash($key, null, $hash);
     $this->assertIdentical($result, 'e38fcb877dccb6a94729a81523851c931a46efb1');
     $result = Security::hash($key, 'sha1', $hash);
     $this->assertIdentical($result, 'e38fcb877dccb6a94729a81523851c931a46efb1');
     $hashType = 'sha1';
     Security::setHash($hashType);
     $this->assertIdentical($this->sut->hashType, $hashType);
     $this->assertIdentical(strlen(Security::hash($key, null, true)), 40);
     $this->assertIdentical(strlen(Security::hash($key, null, false)), 40);
     $this->assertIdentical(strlen(Security::hash($key, 'md5', false)), 32);
     $this->assertIdentical(strlen(Security::hash($key, 'md5', true)), 32);
     $hashType = 'md5';
     Security::setHash($hashType);
     $this->assertIdentical($this->sut->hashType, $hashType);
     $this->assertIdentical(strlen(Security::hash($key, null, false)), 32);
     $this->assertIdentical(strlen(Security::hash($key, null, true)), 32);
     if (!function_exists('hash') && !function_exists('mhash')) {
         $this->assertIdentical(strlen(Security::hash($key, 'sha256', false)), 32);
         $this->assertIdentical(strlen(Security::hash($key, 'sha256', true)), 32);
     } else {
         $this->assertIdentical(strlen(Security::hash($key, 'sha256', false)), 64);
         $this->assertIdentical(strlen(Security::hash($key, 'sha256', true)), 64);
     }
     Security::setHash($_hashType);
 }