Re: PEAR Auth, change password
| From: | Stefan Neufeind | Date: | Wed, 03 Sep 2003 14:15:19 +0000 |
| Subject: | Re: PEAR Auth, change password | ||
| References: | 1 | Groups: | php.pear.dev php.pear.general |
| Request: | Send a blank email to pear-general+get-7551@lists.php.net to get a copy of this message | ||
Hi Walker,
as far as I know there is no such thing like changing a password :-)
But I could offer you this function here which might help you out.
Maybe someone could think of adding some useful features to Auth?
Volunteers? ;-))
Walter, please change the function as needed. It comes directly from
an extended Auth-class we're using here, written on top of the
original Auth and specific to our needs.
function changePassword($password)
{
if (function_exists($this->options['cryptType'])) {
$cryptFunction = $this->options['cryptType'];
} else {
$cryptFunction = "md5";
}
$storage = $this->storage;
$query = sprintf("UPDATE %s SET %s='%s' WHERE %s=%s",
$storage->options['table'],
$storage->options['passwordcol'],
$cryptFunction($password),
'username',
$this->$username
);
$res = $storage->query($query);
if (DB::isError($res)) {
return PEAR::raiseError("", $res->code, PEAR_ERROR_DIE);
} else {
return true;
}
}
Stefan
On 3 Sep 2003 at 9:03, jsWalter wrote:
> Using the Package Auth, how would I change a user passord?
>
> Yes, I can do it directly, hit the database, do a MD5 on it and drop
> it in. But there must be a method to do it within the package, I just
> don't see it.
>
> Thanks for your help.