コード例 #1
0
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $activationHelper = $this->_objectManager->get('LoginRadius\\Activation\\Model\\Helper\\Data');
     $customerRegistrationHelper = $this->_objectManager->get("LoginRadius" . "\\" . $activationHelper->getAuthDirectory() . "\\Model\\Helper\\Data");
     if ($customerRegistrationHelper->enableRaas() != '1') {
         return;
     }
     $events = $observer->getEvent();
     $customer = $events->getCustomerDataObject();
     $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#\$%^&*()_-=?";
     $birthDate = date("m-d-Y", strtotime($customer->getDob()));
     $newUserData = array('emailid' => $customer->getEmail(), 'firstname' => $customer->getFirstname(), 'lastname' => $customer->getLastname(), 'password' => substr(str_shuffle($chars), 0, 8), 'gender' => $this->getGenderValue($customer->getGender()), 'birthdate' => $birthDate);
     $userAPI = new \LoginRadiusSDK\CustomerRegistration\UserAPI($activationHelper->siteApiKey(), $activationHelper->siteApiSecret(), array('authentication' => true, 'output_format' => 'json'));
     $homeDomain = $this->_objectManager->get('Magento\\Store\\Model\\StoreManagerInterface')->getStore()->getBaseUrl();
     if (!isset($_POST['customer']['entity_id'])) {
         try {
             $userCreatedata = $userAPI->create($newUserData);
             try {
                 $rsetPasswordUrl = 'https://api.loginradius.com/raas/client/password/forgot?apikey=' . $activationHelper->siteApiKey() . '&emailid=' . $customer->getEmail() . '&resetpasswordurl=' . $homeDomain . 'customer/account/login/';
                 $result = \LoginRadiusSDK\LoginRadius::apiClient($rsetPasswordUrl, FALSE, array('output_format' => 'json'));
             } catch (\LoginRadiusSDK\LoginRadiusException $e) {
                 $errorDescription = isset($e->getErrorResponse()->description) ? $e->getErrorResponse()->description : '';
                 $this->_messageManager->addError($errorDescription);
             }
             try {
                 $this->socialLinkingData($customer->getId(), $userCreatedata);
             } catch (\Exception $e) {
             }
         } catch (\LoginRadiusSDK\LoginRadiusException $e) {
         }
         return;
     }
 }
コード例 #2
0
 /**
  * LoginRadius function - To fetch social login providers
  *
  * @param string $apikey data to validate.
  *
  * @return object Social Login Providers/error messages.
  *
  * try{
  *   $providers = $GetProvidersAPIObject->getProvidersList();
  * }
  * catch (LoginRadiusException $e){
  *   $e->getMessage();
  * }
  */
 public function getProvidersList()
 {
     $url = LR_CDN_ENDPOINT . "/interface/json/" . LoginRadius::getApiKey() . ".json";
     $response = LoginRadius::apiClient($url);
     $jsonResponse = explode('(', $response);
     if ($jsonResponse[0] == 'loginRadiusAppJsonLoaded') {
         return str_replace(')', '', $jsonResponse[1]);
     }
     throw new LoginRadiusException('Error Retrieving Providers List');
 }
コード例 #3
0
 public function execute()
 {
     $this->_helperActivation = $this->_objectManager->get('LoginRadius\\Activation\\Model\\Helper\\Data');
     $this->_helperCustomerRegistration = $this->_objectManager->get('LoginRadius\\' . $this->_helperActivation->getAuthDirectory() . '\\Model\\Helper\\Data');
     if ($this->_helperCustomerRegistration->enableRaas() != '1') {
         return parent::execute();
     }
     $resultRedirect = $this->resultRedirectFactory->create();
     $accountApi = new \LoginRadiusSDK\CustomerRegistration\AccountAPI($this->_helperActivation->siteApiKey(), $this->_helperActivation->siteApiSecret(), array('authentication' => true, 'output_format' => 'json'));
     $customerId = (int) $this->getRequest()->getParam('customer_id', 0);
     $customer = $this->_customerRepository->getById($customerId);
     $homeDomain = $this->_objectManager->get('Magento\\Store\\Model\\StoreManagerInterface')->getStore()->getBaseUrl();
     try {
         $rsetPasswordUrl = 'https://api.loginradius.com/raas/client/password/forgot?apikey=' . rawurlencode(trim($this->_helperActivation->siteApiKey())) . '&emailid=' . $customer->getEmail() . '&resetpasswordurl=' . $homeDomain . 'customer/account/login/';
         $this->messageManager->addSuccess(__('The customer will receive an email with a link to reset password.'));
     } catch (\LoginRadiusSDK\LoginRadiusException $e) {
         $errorDescription = isset($e->getErrorResponse()->description) ? $e->getErrorResponse()->description : '';
         $this->_messageManager->addError($errorDescription);
     }
     $result = \LoginRadiusSDK\LoginRadius::apiClient($rsetPasswordUrl, FALSE, array('output_format' => 'json'));
     $resultRedirect->setPath('customer/*/edit', ['id' => $customerId, '_current' => true]);
     return $resultRedirect;
 }
コード例 #4
0
ファイル: AccountAPI.php プロジェクト: loginradius/php-sdk
 /**
  * handle account APIs
  *
  * @param type $path
  * @param type $query_array
  * @param type $options
  * @return type
  */
 private function apiClientHandler($path, $query_array = array(), $options = array())
 {
     return LoginRadius::apiClient("/raas/v1/account/" . $path, $query_array, $options);
 }
コード例 #5
0
 /**
  * Social API heandler
  * 
  * @param type $path
  * @param type $raw_data
  * @param type $query_array
  * @param type $options
  * @return type
  */
 private function apiClientHandler($path, $raw_data, $query_array = array(), $options = array())
 {
     $raw = $raw_data ? '/raw' : '';
     return LoginRadius::apiClient("/api/v2/" . $path . $raw, $query_array, $options);
 }