Example #1
0
 /**
  * Authenticate the user
  * 
  * @return Response
  */
 public function store()
 {
     try {
         $userAgent = array("platform" => Useragent::platform(), "browser" => Useragent::browser(), "version" => Useragent::version(), "mobile" => Useragent::mobile(), "robot" => Useragent::robot(), "agent" => Useragent::agent_string(), "accept_lang" => Useragent::accept_lang(), "accept_charset" => Useragent::accept_charset(), "ip_address" => $_SERVER['REMOTE_ADDR']);
         if (Input::get('password')) {
             $authService = new SoapClient(Config::get('wsdl.auth'));
             $token = $authService->authenticateEmail(array("email" => Input::get('email'), "password" => Input::get('password'), "userAgent" => print_r($userAgent, true)));
             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);
             }
         }
     } catch (Exception $ex) {
         return array('error' => $ex->getMessage());
     }
 }
Example #2
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);
     }
 }