Wednesday, September 26, 2012

Re: function beforeFilter

Why not replace all of that with the Auth component?

Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 26 Sep 2012, at 13:38:22, Chris <chris69m@yahoo.com> wrote:

hi euromark,... I have try: 
          // loadModel('user');
  App::import('Model', 'User');
          
still not working...

On Wednesday, September 26, 2012 5:32:25 AM UTC-7, euromark wrote:
maybe its the ancient loadModel() function?


Am Mittwoch, 26. September 2012 14:26:23 UTC+2 schrieb Chris:
hi Jeremy,... can't access the site (secure area) with username and password,... loosing session I think,... can't read user,... and   function beforeFilter()  is in a app-controller.php with settings 

  var $helpers = array('Html', 'Form', 'Time', 'Text', 'Javascript', 'Ajax', 'Session', 'Application', 'User', 'PhotoShow');  
    var $components = array('Cookie', 'RequestHandler', 'Session');
  


On Wednesday, September 26, 2012 5:10:17 AM UTC-7, Chris wrote:
function beforeFilter working on a 1.2,... trying to migrate whole script to 1.3,... 
having problem,... what can be wrong,... ??? please help,... thanks 

  
  function beforeFilter()
  {
    if($this->Session->check('user'))
      $this->user = $this->Session->read('user');
    
    if(!$this->is_user())
    {
      $username = $this->Cookie->read('User.username');
      $hashed_password = $this->Cookie->read('User.hashed_password');
      
      if($username && $hashed_password)
      {
        if(!class_exists('User'))
          loadModel('user');
          
        $User = new User();
        
        if($user = $User->findByUsernameAndHashedPassword($username, $hashed_password))
        {
          $this->Session->write('user', array('id' => $user['User']['id'], 'username' => $user['User']['username'], 'rank' => $user['User']['rank'], 'gender' => $user['User']['gender'], 'firstname' => $user['User']['firstname'], 'lastname' => $user['User']['lastname']));
          $this->set_language($user['User']['language']);
          if($this->Session->check('user'))
            $this->user = $this->Session->read('user');
        }
      }
    }
    



--
Like Us on FacekBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: