Example #1
0
 /**
  * Invokes the user registration on WS.
  *
  * @return response
  * @throws Exception in case of WS error
  */
 public function registerUser()
 {
     try {
         $userService = new SoapClient(Config::get('wsdl.user'));
         $user = new UserModel(Input::all());
         $array = array("user" => $user, "password" => Input::get('password'), "invitationCode" => Input::get('code'));
         if (Input::get('ref')) {
             $array['referrerId'] = Input::get('ref');
         }
         $result = $userService->registerUser($array);
         $authService = new SoapClient(Config::get('wsdl.auth'));
         $token = $authService->authenticateEmail(array("email" => Input::get('email'), "password" => Input::get('password'), "userAgent" => NULL));
         ini_set('soap.wsdl_cache_enabled', '0');
         ini_set('user_agent', "PHP-SOAP/" . PHP_VERSION . "\r\n" . "AuthToken: " . $token->AuthToken);
         Session::put('user.token', $token);
         try {
             $userService = new SoapClient(Config::get('wsdl.user'));
             $result = $userService->getUserByEmail(array("email" => Input::get('email')));
             $user = $result->user;
             /*	if ($user -> businessAccount == true) {
             				if (isset($user -> addresses) && is_object($user -> addresses)) {
             					$user -> addresses = array($user -> addresses);
             				}
             			}  */
             Session::put('user.data', $user);
             return array('success' => true);
         } catch (InnerException $ex) {
             //throw new Exception($ex -> faultstring);
             return array('success' => false, 'faultstring' => $ex->faultstring);
         }
     } catch (Exception $ex) {
         return array('success' => false, 'faultstring' => $ex->faultstring);
     }
 }