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

hakre
  • 193,403
  • 52
  • 435
  • 836
RSK
  • 17,210
  • 13
  • 54
  • 74
  • i just gone through the Authcomponent in that i found a function called identify()------whether overridding that function will solve my problem??? – RSK Jul 03 '10 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. – KahWee Teng Jul 03 '10 at 12:45
  • I think you can build your own authentication component instead of changing the old one. – Young Jul 03 '10 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 – RSK Jul 04 '10 at 14:16

1 Answers1

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.

Community
  • 1
  • 1
deizel.
  • 11,042
  • 1
  • 39
  • 50
  • 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 Jul 04 '10 at 19:29
  • 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. Jul 04 '10 at 23:13