php - (AuthComponent::user('role') in cakephp not returning data correctly in cakephp -


login:

public function login(){     if($this->request->is('post')){          if($this->auth->login($this->request->data)){             return $this->redirect($this->auth->redirecturl());         }else{             $this->session->setflash('invalid username or password');         }     }  } 

this return value:

if(authcomponent::user() 

but when use this:

if((authcomponent::user('role'))==1) 

it does't return value @ all

i can login-logout normally

when authenticating users, attached authentication objects checked in order attached. once 1 of objects can identify user, no other objects checked. sample login function working login form like:

public function login() {     if ($this->request->is('post')) {         // important: use login() without arguments! see warning below.         if ($this->auth->login()) {             return $this->redirect($this->auth->redirecturl());             // prior 2.3 use             // `return $this->redirect($this->auth->redirect());`         }         $this->session->setflash(             __('username or password incorrect'),             'default',             array(),             'auth'         );     } } 

the above code (without data passed login method), attempt log user in using post data, , if successful redirect user either last page visiting, or authcomponent::$loginredirect. if login unsuccessful, flash message set.

in 2.x $this->auth->login($this->request->data) log user in whatever data posted, whereas in 1.3 $this->auth->login($this->data) try identify user first , log in when successful.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -