Authentication in cakephp:
1 - you must build users table in database (Default) that contain
username and password fields (you can change these fields).
2 - in your controller add Auth component :
var $components=array('Auth');
3 - add two functions in your controller :
function login(){}
function logout(){
$this->redirect($this->Auth->logout());
}
(login function body is empty)
4 - now build login.ctp in your view folder with two input fields :
username and password
5 - Done !
now we have simple login system with cakephp power.
you can change default Auth settings :
function beforeFilter() {
$this->Auth->loginRedirect= array
('controller'=>'users','action'=>'index');
$this->Auth->allow('register');
}
On Oct 20, 12:20 pm, xtraorange <[email protected]> wrote:
> Howdy all,
>
> I'm brand new to CakePHP (and MVC frameworks for that matter), but
> perfectly comfortable with php and mysql.
>
> For a number of years I have hand written and reused my own
> authentication systems, which have worked fantastically for me. Now
> that I've found the benefit of CakePHP, I'd really like to recreate my
> way of doing authentications.
>
> My question:
> I'll give a short summary below as to how I go about doing it, but my
> question is this: does anyone have a good tutorial or write up they
> know of that I could follow for overwriting the existing auth system
> with my own with the least amount of effort?
>
> ---
>
> How I like to do authentications:
> Users of course have an ID, username and hashed pass, which is checked
> on a login attempt and set up in the sessions. They also have a user
> level, ranking them numerically (in most cases, I use 1-5, or 1-10...
> the higher you are, the more rights you have)... this includes 0 for
> guests, 1 for users who are registered but have not been authenticated
> (depending on if the system has admin or e-mail authentication turned
> on), and 2+ for everyone else. Most of my pages have a numerical
> value indicating the required level to enter (for example, if it were
> 3... all users level three and up could enter), though some instead
> use an array and a numerical value (for exceptions... so 3 is the
> numeral, but in the array 5 is false... then everyone 3+ except level
> 5 users have access). I like this system because it allows me to have
> precise controll over which groups access, without having to manage in
> fine detail every last thing (because of the numerical value, most
> pages require that only and they are ready to go). The global
> function also lets me use this same check for things like menu items
> (register, admin panel, etc.).
>
> Thanks,
> x.o.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---