2005-11-18
grantroot
If one logs in as a superuser, clicks "Admin", clicks "Add new user...", fills out the form, and clicks "Register", the new user will be created but a mail error is reported ("Looks like there was an error on sending the password mail. Please contact the admin!") and the password will not be mailed to the user.
(Assumption: the authtype being used is the default "plain". I haven't tested with other authtypes.)
This is caused by the fact that the function auth_getUserData caches the $users array (from the users.auth.php file) as a static variable, and will not re-fetch the data after the first time the file is read. In the case outlined above, this cacheing causes the following sequence of events:
1) In function auth_login, auth_getUserData is called to get data for the currently logged-in user. This caches $users.
2) In function register, auth_createUser is called, which adds the user to the users.auth.php file.
3) In function auth_sendPassword, auth_getUserData is called to get data for the new user. However, the $users data is already cached and is not reread from the users.auth.php file.
4) A mail error is issued ("Looks like there was an error on sending the password mail. Please contact the admin!").
FIX: A workaround is to simply remove the conditional test from function auth_getUserData so that the user data is reread from the file each time the function is called. The ultimate fix will probably involve setting some kind of "dirty" flag to invalidate the cached user data when a new user is created.