Hello,

      I have an AdminsController class that uses User model to validate the 
username and password. the app_controller's before filter looks like this

 

    public function beforeFilter()
 {
  $this->set('site_url', 'http://localhost/cake/');
  
  //Override default fields used by Auth component
        $this->Auth->fields = 
array('username'=>'email_address','password'=>'password');
  
  
  $this->Auth->loginAction = array('controller' => 'admins', 'action'=> 
'login');
  $this->Auth->logoutRedirect = array('controller'=> 'admins', 'action' 
=>'login');
  $this->Auth->loginError = __('Invalid username or password', true);
  //$this->Auth->authError = __(' ', true);  //this is for now.
  
  $this->Auth->loginRedirect = array(
   'controller' => 'admins',
   'action' => 'manage_users'
  );

  //$this->set('admin', false);
    }

 

After it logs in I dont see Auth component setting User information in session. 
I want the user to login before using any other page.

 

My AdminsControllers beforeFilter and login() looks like this

 

 public function beforeFilter()
 {
  parent::beforeFilter();
  $this->Auth->allow('login');
 }
 
 function login()
 {
  $this->Session->write('userrole', '');

  if(isset($this->data))
  {
   //echo pr($this->data);
   $temp = 
$this->User->find(array('email_address'=>$this->data['User']['email_address']));
   //echo pr($this->Auth);
   $this->Session->write('userrole', $temp['Group'][0]['name']);
   //$this->Session->write('user_logged_id', $this->Auth['data']['username']);
   //once admin user logs in, he is redirected to manage users' page
   $this->redirect('/admins/manage_users');
  }
 }

 

Whats happening is everytime i login with correct password, I get Auth error '

You are not authorized to access that location.' and it goes back to login page 
again. In the function login, the echo pr($this->data); has empty string for 
password.
 
Any pointers?
 
Thanks,
Bharani
 
_________________________________________________________________
Lauren found her dream laptop. Find the PC that’s right for you.
http://www.microsoft.com/windows/choosepc/?ocid=ftp_val_wl_290
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to