0

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

4
  • i just gone through the Authcomponent in that i found a function called identify()------whether overridding that function will solve my problem??? Commented Jul 3, 2010 at 11:08
  • How different is your table? Does it still have the username and password or equivalent still in one table? You can set those field names if it's different. Commented Jul 3, 2010 at 12:45
  • I think you can build your own authentication component instead of changing the old one. Commented Jul 3, 2010 at 12:46
  • in my table the username and password is stored as different records and for identifing the paires an extra field is placed Commented Jul 4, 2010 at 14:16

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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????
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).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.