Example #1
0
 public static function getUser4()
 {
     static $user;
     if (!isset($user)) {
         $user = new Api_Dao_User();
         $user->setId(10004);
         $user->setUsername("test user 4");
         $user->setPassword("test password 4");
     }
     return $user;
 }
Example #2
0
 /**
  * Creates the user if it's not in the DB.  Throws an exception if the user already exists!
  *
  * @return Array[user][id]
  * @throws Exception
  */
 public function execute()
 {
     //make sure calling application is a default application
     $this->checkDefaultApp();
     require_once AUTH_PLUGINS . $type . '.php';
     $method = new $className();
     $userid = $method->findUser($apiParams);
     if (!empty($userid)) {
         throw new OpenFBAPIException("User credentials already exist!", 1);
     }
     if (!empty($linked)) {
         // Link a give UID to a set of credentials.
         $user = RingsideOpenFBDbAuth::findUser($linked);
         if ($user === false) {
             throw new OpenFBAPIException("Linked UID does not exist", 1);
         }
         $method->linkUser($linked, $apiParams);
     } else {
         $user = new RingsideOpenFBDbAuth();
         $user->setNid($this->getNetworkId());
         $user->insertIntoDb($this->getDbCon());
     }
     $user = new Api_Dao_User();
     $user->setUsername($this->user_name);
     $user->setPassword($this->password);
     $response = array();
     if (!$user->initByUserName($this->user_name)) {
         $user->insertIntoDb($this->getDbCon());
         $response['user'] = array();
         $response['user']['id'] = $user->getId();
     } else {
         throw new Exception("User {$this->user_name} already exists!");
     }
     return $response;
 }
Example #3
0
 public function testautoincrementIntoDb()
 {
     $dbCon = RsOpenFBDbTestUtils::getDbCon();
     $password = "******";
     $username = "******";
     $user = new Api_Dao_User();
     $user->setUsername($username);
     $user->setPassword($password);
     try {
         $numRows = $this->getNumAllUsers($dbCon);
         $this->assertNull($user->getId());
         $user->insertIntoDb($dbCon);
         $this->assertEquals($numRows + 1, $this->getNumAllUsers($dbCon));
         $this->assertNotNull($user->getId());
         $row = $this->getUser($dbCon, $user->getId());
         $this->assertEquals($user->getId(), $row[id]);
         $this->assertEquals($password, $row['password']);
         $this->assertEquals($username, $row['username']);
     } catch (Exception $exception) {
         $user->deleteFromDb($dbCon);
         throw $exception;
     }
     $user->deleteFromDb($dbCon);
     $this->assertEquals($numRows, $this->getNumAllUsers($dbCon));
 }
Example #4
0
 }
 if (!validateName($name)) {
     loadErrorClass($flavor, 'Please specify a first and last name');
     return;
 }
 if (!validatePassword($password)) {
     loadErrorClass($flavor, 'Password must be specified');
     return;
 }
 $uid = null;
 try {
     $dbCon = RingsideApiDbDatabase::getDatabaseConnection();
     //$client->api_client->admin_createUser($email, $password);
     $user = new Api_Dao_User();
     $user->setUsername($email);
     $user->setPassword(sha1($password));
     if (!$user->initByUserName($email, $dbCon)) {
         try {
             $user->insertIntoDb($dbCon);
             saveName($user->getId(), $name);
             $uid = $user->getId();
             error_log("REGISTERED NEW ONE " . $user->getId());
         } catch (Exception $e) {
             $error = 'Failed to create user: '******'User already exists!';
     }
 } catch (Exception $e) {
     $error = 'Registration Error: ' . $e->getMessage();
 }