Tuesday, February 3, 2009

Auth - Login with Username OR Email

Hi,

I was wondering if anyone knows how to set the Auth component to allow
login using either:

Email + Password

OR

Username + Password

I have seen lots of site that do this but can't work out how to do it
in Cake.

I have tried the below which doesn't work:

[CODE]
if ( $this->Auth->login( $this->data ) ) {
$this->render('success');
} else {
$this->Auth->fields = array('username' => 'username', 'password'
=> 'password');
$this->data['User']['username'] = $this->data['User']['email'];
if ( $this->Auth->login( $this->data ) ) {
$this->render('success');
} else {
echo "Login Failed";
}
}
[/CODE]

Any other ideas?

Cheers

Mike
--~--~---------~--~----~------------~-------~--~----~
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
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: