views:

51

answers:

1

how can i use myown login function to authenticate users in cakePHP
because my users table structure is different from the cakePHP structure.

even i overridden the login function it still executing the login function in parent class

can any one provide me a solution for this??

thanks in advance

+1  A: 

When using models that don't reflect CakePHP's conventions, there are a few things you can configure to get things working.

When you create your User model (or whatever you have called it), you can specify which database the table is in, what the name of the table is, if the table has a prefix, what the primary key field is called (usually id), and what the display field is (usually name or title).

When setting up AuthComponent, you can also specify what model to use (usually User) and what the username and password fields are called.

A combination of the above configuration options should usually be enough to get CakePHP understanding how to your table schema is set up.

However, in some cases this isn't enough, so you can override or extends parts of the core AuthComponent to get it working the way you want (usually just the identify method is needed, as you pointed out). A few example scenarios would be LDAP authentication, trying to authenticate over multiple User tables, and trying to authenticate where there are joined User and Email tables.

deizel
@deizel :in Auth the startup() calls login() and login calls identify(). i need the functionality of startup() an dlogin as it is and change the functionality of identify(). is there any way to do this using overriding????
RSK
Yes, if you check the last three links in my answer, those examples only override `identify()` (`startup()` and `login()` remain the same as in the core).
deizel
thank yaar it worked............
RSK