2

I have a database with the following tables:

CREATE TABLE `visitors` (
`name` varchar(64) not null,
`id` int(10) unsigned not null auto_increment,
 # ...more fields here  
 PRIMARY KEY (`id`),
 UNIQUE KEY (`name`)
 );

 CREATE TABLE `credentials` (
 `id` int(10) unsigned not null auto_increment,
 `visitor_id` int(10) unsigned,
 `type` enum('password','openid','google','facebook') not null,
 `token` char(40) not null,
 `modified` datetime,
 `hint` varchar(64),
  PRIMARY KEY (`id`),
  KEY `visitor` (`visitor_id`),
  KEY `token` (`token`)
  );

After thinking about this for a awhile, I've decided that this is "right" for e.g. normalization and allowing visitors to have multiple login credentials, including multiple passwords.

However, I'd like to use Cake's ACL features, and AuthComponent assumes that hashed passwords are stored in the same table as user (visitor) information. What's the best way to work around this? Do I have to use Auth->login(), or is there a better way?

  • 1
    take a look at http://stackoverflow.com/questions/1677532/cakephp-auth-component-using-2-tables – minaz Oct 26 '11 at 17:00

1 Answers1

0

If you're using CakePHP 2.x this can be archived pretty simple by creating a new authentication handler. Looking at the existing Form handler will also help you. You should be able to extend it or copy the code into a new handler and modify it to match your needs.

Read the authentication chapter in the book. It has a section just about creating a custom handler but to get an understanding of how the whole thing works I really suggest you to read the whole page.

floriank
  • 25,546
  • 9
  • 42
  • 66