[development] authentication hooks - PLEASE HELP

Robert Douglass rob at robshouse.net
Sun Dec 18 21:59:22 UTC 2005


Hi Sheryl,

Please show us some code. A great way to do this is with 
http://pastebin.com/

Just go there, fill in the form, and post the URL here for people to 
look at.


Sheryl (Permutations Software) wrote:
> - Which hook functions are called when (and not just from within the Drupal
> code, but from what user action)? I thought that hook_auth() might be called
> when the user logged in (that was a wild guess), but I can't get Drupal to
> call this function no matter what I do.

1) Is the function called hook_auth or yourmodule_auth() ?

2) Is your login attempt failing because Drupal is authenticating the 
user the normal way? Drupal doesn't call the auth hook if the user gets 
authenticated successfully by Drupal.


> - What values are set in the database to control authentication, and what
> does each value mean? In particular, what is the meaning of the different
> values for "status" in the user table?

This is a very good point. We've been slowly weaning ourselves from 
things like if ($user['status'] > 3) and moving to replacing 3 with a 
meaningful constant to be human readable. Please open an issue on the 
user module, mark it as 'task', and describe that this should be done 
for the user module. Better yet, when you figure out what the various 
meanings of 1, 2, 3 and whatever are, define the variables, replace the 
numbers, and roll a patch. It could become your first contribution to 
Drupal core.


> - How can I echo values while the script is executing to I can debug my
> modules???????????????

The normal way. You have to find a place where the code actually gets 
called, so if your auth hook isn't getting called, you've got to fix 
that first. I always do this: print_r($vals); exit(); If you have the 
devel module installed, you can use dprint_r instead (it formats it 
nicely). Others have other debugging styles.

Don't forget that it is Sunday... very slow time for the devel list.

-Robert



More information about the development mailing list