On Thu, Feb 5, 2009 at 11:49 PM, datgs <[email protected]> wrote:

>
> Hi everybody,
>
> I've had to rewrite code in AuthComponent class to login with username
> only.
>
> Was it the best way for my purpose. Is there any way without changing
> the code in AuthComponent.
>

I had to do this as I wanted a site that was protected by lots of unique
codes (ie. usernames) but no passwords. The way I did it was by doing the
following in my users_controller.php:

function beforeFilter() {
   parent::beforeFilter();
   $this->Auth->fields['password'] = 'username';
   $this->Auth->authenticate = $this->User;
}

.. and in my user.php model:

function hashPasswords( $data ) {
    return $data;
}

The hashPasswords() function basically returns the password as is (in
clear-text) so that I can lookup the code in my users table. I just have a
"username" column and no password column.

I doubt this is the ideal way to do it, but it works for me.

- Gonzalo

--~--~---------~--~----~------------~-------~--~----~
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