From 9aef63d9e9630794736abdf4b05b7062a591ab09 Mon Sep 17 00:00:00 2001 From: "Duck (Jakob Munih)" Date: Thu, 29 Oct 2009 04:43:39 +0100 Subject: [PATCH] Add authResetPassword method --- folks/lib/Application.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/folks/lib/Application.php b/folks/lib/Application.php index 8ecef10ca..973618cb5 100644 --- a/folks/lib/Application.php +++ b/folks/lib/Application.php @@ -115,6 +115,30 @@ class Folks_Application extends Horde_Registry_Application } /** + * Reset a user's password. Used for example when the user does not + * remember the existing password. + * + * @param string $userId The user id for which to reset the password. + * + * @return string The new password on success. + * @throws Horde_Auth_Exception + */ + public function authResetPassword($userId) + { + /* Get a new random password. */ + $password = Horde_Auth::genRandomPassword(); + + /* Update password in DB. */ + require_once dirname(__FILE__) . '/base.php'; + $result = $GLOBALS['folks_driver']->changePassword($password, $userId); + if ($result instanceof PEAR_Error) { + throw new Horde_Auth_Exception($result); + } + + return $password; + } + + /** * Deletes a set of authentication credentials. * * @param string $userId The userId to delete. -- 2.11.0