I suppose you could put the logic in beforeFilter(). If the
$this->params['action'] == 'login' check for
$this->data['User']['username'] and, if it's empty (and email isn't)
do"

$this->data['User']['username'] $this->data['User']['email'];

I don't understand why you'd want to do this, though. Are you sure
that these other sites which allow email for username don't simply do
that for all users? That's pretty common. I don't recall ever seeing a
site which allowed either.

On Tue, Feb 3, 2009 at 11:54 AM, Mike Digital Egg
<[email protected]> wrote:
>
> 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 [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