Hi guys,

I'm quite new to Cake, so forgive me if any of this sounds stupid/
unnecessary. I've been playing around with Cake 1.2's Auth component,
and found that there were a few things slightly awry with it:

- If you put 'login' or '*' in the allowed actions, the login code is
never called, meaning you have to fill in the controller's login()
function yourself (a lot of people seem to have been doing this)
- Passwords are always hashed (in any action) if the username is also
passed. This can mess up the registration process because you can't
perform validation checks on a hashed password
- Login succeeds on a blank username and password
- The component seems to ignore loginRedirect and always redirects
back to the referring page

Anyway, to fix these things I wrote a component that extends Auth,
called Cauth. You can view the code for it here:

http://www.coldrose.com/cake/cauth.txt

I also added some functionality that I felt was missing:

- If you add 'last_login' to the $fields array, the component will
automatically set the last login datetime for the user when they log
in
- You can automatically store data from models other than the
$userModel in the session, and access them through the user() function
- In addition to setting the component's $allowedActions, you can
specify which actions should always be allowed (even if not logged in)
by setting the $allow array in the appropriate controller. This saves
clogging up the beforeFilters with $auth->allow() calls
- You can specify an action to redirect to if the authorization fails,
or you can choose to always redirect back to the last page
- You can specify messages to flash when the user logs in successfully
and when the user needs to be logged in and is redirected to the login
page
- The controller is automatically made available in views via the
$cauth variable


Anyway, I'm posting it here in case anyone finds it useful, and as a
suggestion as to how the Auth component might want to evolve. I've
tried to put in as many comments as possible, so it should be
relatively easy to figure out. To use it, just download the file,
rename it to cauth.php and put it in your components directory. You'll
need to look through the global vars at the top to get an idea of how
it works.

Hope this helps someone,

David


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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