Re: PEAR::Auth via FILE - possible bug
| From: | Yavor Shahpasov | Date: | Thu, 10 Jun 2004 06:45:45 +0000 |
| Subject: | Re: PEAR::Auth via FILE - possible bug | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-30362@lists.php.net to get a copy of this message | ||
There was a but when options passed to Auth is not an array. Try the latest realease Auth 1.3.0r1 <http://pear.php.net/package/Auth/> it is fixed there
y.
[php]Walter wrote:
It is 11:30 pm CST. Exactly 18 hours after I started working on this. Something I thought would take no more than 1. I figured I could modify my DB based Auth example files to work with FILE, since DB works, and FILE and other containers should be semi-transparent to this, it should be a piece of cake. Yea, right. This piece of code (thanks Yavor) works fine, as far as it goes... $objAuth = &new Auth("File", 'user.file', 'loginFunction');-- Yavor Shahpasov yavo@siava.org Linux is not The Answer. Yes is the answer. Linux is The Question.$objAuth->addUser($username, $password);The user is added to the file and the password is encrypted. All well and good. This will also remove a user. But, the same &new Auth(...) line does not authenticate. Period Seems that the current version of Auth demands that the $options parameter be an array. And that 2 elements of that array be... "usernamecol" => "username" "passwordcol" => "password" And that the values of these keys be the field names given to the FORM fields of the login screen. [BTW: I tested this again in the DB file set. Changed the 'usernamecol' value to 'uID', changed the form field name to 'uID', and the column name in the DB to 'uID'. It worked just fine. Can some please update the doc in Auth::DB to reflect this?] If $options is not an array, but a simple string as the code from Yavor indicated (which works for add and remove) the first letter of the file name is used as the session name, the 'usernamecol' value and the 'passwordcol' value. So, this leaves "us" in a pickle. Auth wants this parameter to be an array, but the FILE extension assumes it's a file path string. This is a one (1) line fix. Auth::CONTAINER::FILE Line 57:$this->pwfile = $filename;to this:$this->pwfile = $filename['file'];I didn't change the parameter name, but that probably would be a good idea. In fact, it should a check to see if the value passed is a string or an array, and then assign a value to $this->pwfile accordingly. But I'll leave that to those who know better than I. With this "fix" in place, the doc for Auth::FILE needs to indicate that the $options parameter for this container needs to be an array, thus: // Parameters for FILE access in Auth$params = array( "file" => '/path/to/file', // file to use "usernamecol" => "username", // login form field name foruser id"passwordcol" => "password" // login form field name foruser password);Now, this "fix" is just my recommendation. I have no idea how this will cascade with BC, or not. I image those who know more than I can best determine how to make this work. Now, I may be COMPLETELY wrong on this. I may not have a clue of what needs to happen to make FILE authenticate in its current form. But, if I don't, I hoping that someone will inform me (with code please) on how to authenticate with FILE. Thanks Walter