Re: CakePHP 2.4 Auth->login() always return TRUE ... ?

2015-06-07 Thread Rawal Hardik
I have same issue! Code seems almost seems.
Can anyone please help me out???plz

-- appcontroller

 array(
'loginRedirect' => array(
'controller' => 'users',
'action' => 'index'
),
'loginAction' => array('controller' => 'users', 'action' => 
'login'),

'logoutRedirect' => array(
'controller' => 'users',
'action' => 'login',
),'authorize' => array('Controller')

)
);


public function beforeFilter() {
  $this->Auth->allow('index', 'view','login');
}
}
?>

login.ctp


Session->flash('auth'); ?>
Form->create('User'); ?>




Form->input('username');
echo $this->Form->input('password');
?>

Form->end(__('Login')); ?>


controller

public function login() { 
 
if ($this->request->is('post')) {

 $this->Auth->authenticate['Form'] = array('fields' => array('username' 
=> 'username'));
 //$this->request->data['User']['id'] = $this->User->id; 
 debug($this->request->data);
if ($this->Auth->login()) {
 $this->Session->setFlash(sprintf("Welcome %s!", 
$this->Auth->user('username')));
return $this->redirect($this->Auth->redirect());
}
$this->Session->setFlash(__('Invalid username or password, try 
again'));
}
}

help plz

On Tuesday, 15 April 2014 17:16:56 UTC+5:30, MedAL wrote:
>
> Hello,Iread the documentation to create a simple login form.each time I 
> try to log in it returns true  always;
>
> //UsersController
> public function login() { 
>  if ($this->Auth->user()) {
> $this->redirect($this->Auth->redirect());
> }
>
> if ($this->request->is('post')) {
>
>  $this->Auth->authenticate['Form'] = array('fields' => 
> array('username' => 'username'));
>  $this->request->data['User']['id'] = $this->User->id; 
>  debug($this->request->data);
> if ($this->Auth->login($this->request->data['User'])) {
>  $this->Session->setFlash(sprintf("Welcome %s!", 
> $this->Auth->user('username')));
> return $this->redirect($this->Auth->redirect());
> }
> $this->Session->setFlash(__('Invalid username or password, try 
> again'));
> }
> }
>
>
>
>
>
> //AppController
> class AppController extends Controller {
>
> public $components = array(
> 'Session',
> 'Auth' => array(
> 'loginRedirect' => array(
> 'controller' => 'Events',
> 'action' => 'index'
> ),
> 'loginAction' => array('controller' => 'Users', 'action' => 
> 'login'),
>
> 'logoutRedirect' => array(
> 'controller' => 'Users',
> 'action' => 'login',
> 'home'
> ),'authorize' => array('Controller')
>
> )
> );
>
> public function beforeFilter() {
> //parent::beforeFilter();
> $this->Auth->allow('index', 'view','login');
> /* $this->Auth->authenticate = array(
> 'Basic' => array('userModel' => 'User'),
> 'Form' => array('userModel' => 'User')
> );*/
>
> }
>
>
>
> //login.ctp
>
>
> 
> Session->flash('auth'); ?>
>
> Form->create('User'); ?>
>
> 
> 
> 
> 
> Form->input('username'); 
> echo $this->Form->input('password');
> ?>
> 
> Form->end(__('Login')); ?>
> 
>

-- 
Like Us on FaceBook 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 unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP 2.4 Auth->login() always return TRUE ... ?

2014-12-08 Thread Yomi Ojo


On Wednesday, April 16, 2014 5:59:47 PM UTC+1, euromark wrote:
>
> You are like the 400th person who didnt read that part of the 
> documentation in 2.x
>
> http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#identifying-users-and-logging-them-in
> (red warning box)
>
> if ($this->Auth->login($this->request->data['User'])) {}
> always logs this data in
>
> you need:
>
> if ($this->Auth->login()) {}
>
>
>
> Am Dienstag, 15. April 2014 13:46:56 UTC+2 schrieb MedAL:
>>
>> Hello,Iread the documentation to create a simple login form.each time I 
>> try to log in it returns true  always;
>>
>> //UsersController
>> public function login() { 
>>  if ($this->Auth->user()) {
>> $this->redirect($this->Auth->redirect());
>> }
>>
>> if ($this->request->is('post')) {
>>
>>  $this->Auth->authenticate['Form'] = array('fields' => 
>> array('username' => 'username'));
>>  $this->request->data['User']['id'] = $this->User->id; 
>>  debug($this->request->data);
>> if ($this->Auth->login($this->request->data['User'])) {
>>  $this->Session->setFlash(sprintf("Welcome %s!", 
>> $this->Auth->user('username')));
>> return $this->redirect($this->Auth->redirect());
>> }
>> $this->Session->setFlash(__('Invalid username or password, try 
>> again'));
>> }
>> }
>>
>>
>>
>>
>>
>> //AppController
>> class AppController extends Controller {
>>
>> public $components = array(
>> 'Session',
>> 'Auth' => array(
>> 'loginRedirect' => array(
>> 'controller' => 'Events',
>> 'action' => 'index'
>> ),
>> 'loginAction' => array('controller' => 'Users', 'action' => 
>> 'login'),
>>
>> 'logoutRedirect' => array(
>> 'controller' => 'Users',
>> 'action' => 'login',
>> 'home'
>> ),'authorize' => array('Controller')
>>
>> )
>> );
>>
>> public function beforeFilter() {
>> //parent::beforeFilter();
>> $this->Auth->allow('index', 'view','login');
>> /* $this->Auth->authenticate = array(
>> 'Basic' => array('userModel' => 'User'),
>> 'Form' => array('userModel' => 'User')
>> );*/
>>
>> }
>>
>>
>>
>> //login.ctp
>>
>>
>> 
>> Session->flash('auth'); ?>
>>
>> Form->create('User'); ?>
>>
>> 
>> 
>> 
>> 
>> Form->input('username'); 
>> echo $this->Form->input('password');
>> ?>
>> 
>> Form->end(__('Login')); ?>
>> 
>>
>

Thanks Euromark, I am the 401th person. It was really helpful  and useful  

-- 
Like Us on FaceBook 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 unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP 2.4 Auth->login() always return TRUE ... ?

2014-04-16 Thread euromark
You are like the 400th person who didnt read that part of the documentation 
in 2.x
http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#identifying-users-and-logging-them-in
(red warning box)

if ($this->Auth->login($this->request->data['User'])) {}
always logs this data in

you need:

if ($this->Auth->login()) {}



Am Dienstag, 15. April 2014 13:46:56 UTC+2 schrieb MedAL:
>
> Hello,Iread the documentation to create a simple login form.each time I 
> try to log in it returns true  always;
>
> //UsersController
> public function login() { 
>  if ($this->Auth->user()) {
> $this->redirect($this->Auth->redirect());
> }
>
> if ($this->request->is('post')) {
>
>  $this->Auth->authenticate['Form'] = array('fields' => 
> array('username' => 'username'));
>  $this->request->data['User']['id'] = $this->User->id; 
>  debug($this->request->data);
> if ($this->Auth->login($this->request->data['User'])) {
>  $this->Session->setFlash(sprintf("Welcome %s!", 
> $this->Auth->user('username')));
> return $this->redirect($this->Auth->redirect());
> }
> $this->Session->setFlash(__('Invalid username or password, try 
> again'));
> }
> }
>
>
>
>
>
> //AppController
> class AppController extends Controller {
>
> public $components = array(
> 'Session',
> 'Auth' => array(
> 'loginRedirect' => array(
> 'controller' => 'Events',
> 'action' => 'index'
> ),
> 'loginAction' => array('controller' => 'Users', 'action' => 
> 'login'),
>
> 'logoutRedirect' => array(
> 'controller' => 'Users',
> 'action' => 'login',
> 'home'
> ),'authorize' => array('Controller')
>
> )
> );
>
> public function beforeFilter() {
> //parent::beforeFilter();
> $this->Auth->allow('index', 'view','login');
> /* $this->Auth->authenticate = array(
> 'Basic' => array('userModel' => 'User'),
> 'Form' => array('userModel' => 'User')
> );*/
>
> }
>
>
>
> //login.ctp
>
>
> 
> Session->flash('auth'); ?>
>
> Form->create('User'); ?>
>
> 
> 
> 
> 
> Form->input('username'); 
> echo $this->Form->input('password');
> ?>
> 
> Form->end(__('Login')); ?>
> 
>

-- 
Like Us on FaceBook 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 unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


CakePHP 2.4 Auth->login() always return TRUE ... ?

2014-04-16 Thread MedAL
Hello,Iread the documentation to create a simple login form.each time I try 
to log in it returns true  always;

//UsersController
public function login() { 
 if ($this->Auth->user()) {
$this->redirect($this->Auth->redirect());
}

if ($this->request->is('post')) {

 $this->Auth->authenticate['Form'] = array('fields' => array('username' 
=> 'username'));
 $this->request->data['User']['id'] = $this->User->id; 
 debug($this->request->data);
if ($this->Auth->login($this->request->data['User'])) {
 $this->Session->setFlash(sprintf("Welcome %s!", 
$this->Auth->user('username')));
return $this->redirect($this->Auth->redirect());
}
$this->Session->setFlash(__('Invalid username or password, try 
again'));
}
}





//AppController
class AppController extends Controller {

public $components = array(
'Session',
'Auth' => array(
'loginRedirect' => array(
'controller' => 'Events',
'action' => 'index'
),
'loginAction' => array('controller' => 'Users', 'action' => 
'login'),

'logoutRedirect' => array(
'controller' => 'Users',
'action' => 'login',
'home'
),'authorize' => array('Controller')

)
);

public function beforeFilter() {
//parent::beforeFilter();
$this->Auth->allow('index', 'view','login');
/* $this->Auth->authenticate = array(
'Basic' => array('userModel' => 'User'),
'Form' => array('userModel' => 'User')
);*/

}



//login.ctp



Session->flash('auth'); ?>

Form->create('User'); ?>





Form->input('username'); 
echo $this->Form->input('password');
?>

Form->end(__('Login')); ?>


-- 
Like Us on FaceBook 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 unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.