From e12fb9d4a6f5cf5bde54e4af70cd16486ec6bdc3 Mon Sep 17 00:00:00 2001 From: "Duck (Jakob Munih)" Date: Mon, 19 Oct 2009 18:06:33 +0200 Subject: [PATCH] Update with new Auth code --- folks/lib/Application.php | 11 +++++++---- folks/lib/Driver/sql.php | 11 ++++++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/folks/lib/Application.php b/folks/lib/Application.php index 38d70483b..34cc0b371 100644 --- a/folks/lib/Application.php +++ b/folks/lib/Application.php @@ -98,14 +98,18 @@ class Folks_Application extends Horde_Registry_Application * Adds a set of authentication credentials. * * @param string $userId The userId to add. + * @param array $credentials The credentials to use. * - * @return boolean True on success or a PEAR_Error object on failure. + * @throws Horde_Exception */ - public function authAddUser($userId) + public function authAddUser($userId, $credentials) { require_once dirname(__FILE__) . '/base.php'; - return $GLOBALS['folks_driver']->addUser($userId); + $result = $GLOBALS['folks_driver']->addUser($userId, $credentials); + if ($result instanceof PEAR_Error) { + throw new Horde_Exception($result); + } } /** @@ -122,7 +126,6 @@ class Folks_Application extends Horde_Registry_Application return $GLOBALS['folks_driver']->deleteUser($userId); } - /** * Deletes a user and its data * diff --git a/folks/lib/Driver/sql.php b/folks/lib/Driver/sql.php index 7c1c519dc..2165ca3b5 100644 --- a/folks/lib/Driver/sql.php +++ b/folks/lib/Driver/sql.php @@ -408,15 +408,20 @@ class Folks_Driver_sql extends Folks_Driver { } /** - * Add dummy user data + * Adds a set of authentication credentials. + * + * @param string $userId The userId to add. + * @param array $credentials The credentials to use. + * + * @return boolean true|PEAR_Error */ - public function addUser($user) + public function addUser($user, $credentials) { // password and mail will be added later with the addextra hook $query = 'INSERT INTO ' . $this->_params['table'] . ' (user_uid, user_status, user_password, user_email, signup_at, signup_by) ' . ' VALUES (?, ?, ?, ?, NOW(), ?)'; - $params = array($user, 'inactive', rand(), + $params = array($user, 'inactive', $credentials['password'], rand() . '@' . $_SERVER['REMOTE_ADDR'], $_SERVER['REMOTE_ADDR']); -- 2.11.0