/** * 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; }
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(); } if (!isset($error) || empty($error) || strlen($error) == 0) {