Hi, so I have a simple module that uses hook_auth for testing purposes:

function remote_db_auth($username,$password)
{
	watchdog('remote_db_auth','accessing');
	return true;
}	

So if I try to login with a user that doesn't exist in my Drupal user database, it should create it, correct? However, when I try to login with a username that doesn't exist (joe), it gives me the typical unrecognized username or password error, plus no watchdog entry in the logs. I've also tried joe@domain.com, etc. No matter what I try, I can't get the watchdog entry nor the username created. Why isn't the hook_auth being called? Is there a hidden setting somewhere I need to enable?

I don't know what else to try. I've search and most people seem to have hook_auth working.

Comments

nevets’s picture

Well first to check, your module is called 'remote_db' correct?

Second your function is missing a parameter, it should be declared as

function remote_db_auth($username, $password, $server)
aniskhan’s picture

I had named my module remote_db_auth :| unbelievable....

So i changed everything to remote_db and now it works :)

But i get 4 errors in red upon login of the newly created user, and then when the page is refreshed, the errors disappear...

  • warning: array_keys() [function.array-keys]: The first argument should be an array in E:\wwwroot\pan_d5\modules\user\user.module on line 378.
  • warning: array_fill() [function.array-fill]: Number of elements must be positive in E:\wwwroot\pan_d5\modules\user\user.module on line 379.
  • warning: implode() [function.implode]: Bad arguments. in E:\wwwroot\pan_d5\modules\user\user.module on line 379.
  • user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
  • query: SELECT DISTINCT(p.perm) FROM role r INNER JOIN permission p ON p.rid = r.rid WHERE r.rid IN () in E:\wwwroot\pan_d5\includes\database.mysqli.inc on line 151.

    Regarding the missing parameter, it seems like hook_auth does $server = false as one of the parameters.

  • nevets’s picture

    Your hook should declare all parameters show in the docs.

    As for the errors I can not tell from the error if this is from code in your module or some other problem. Either way it would require some time debugging the problem.

    aniskhan’s picture

    :)