Update with new Auth code
authorDuck (Jakob Munih) <duck@obala.net>
Mon, 19 Oct 2009 16:06:33 +0000 (18:06 +0200)
committerDuck (Jakob Munih) <duck@obala.net>
Mon, 19 Oct 2009 16:06:33 +0000 (18:06 +0200)
folks/lib/Application.php
folks/lib/Driver/sql.php

index 38d7048..34cc0b3 100644 (file)
@@ -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
      *
index 7c1c519..2165ca3 100644 (file)
@@ -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']);