예제 #1
0
 /**
  * Tests the "ssoLogin" method for the NostoAccount class.
  */
 public function testAccountSingleSignOn()
 {
     $account = new NostoAccount('platform-test');
     $meta = new NostoAccountMetaDataIframe();
     $this->specify('account sso without api token', function () use($account, $meta) {
         $this->assertFalse($account->ssoLogin($meta));
     });
 }
예제 #2
0
 /**
  * Returns the url for the account administration iframe.
  * If the passed account is null, then the url will point to the start page where a new account can be created.
  *
  * @param NostoAccountMetaDataIframeInterface $meta the iframe meta data.
  * @param NostoAccount|null $account the account to return the url for.
  * @param array $params additional parameters to add to the iframe url.
  * @return string the iframe url.
  * @throws NostoException if the url cannot be created.
  */
 public function getUrl(NostoAccountMetaDataIframeInterface $meta, NostoAccount $account = null, array $params = array())
 {
     $queryParams = http_build_query(array_merge(array('lang' => strtolower($meta->getLanguageIsoCode()), 'ps_version' => $meta->getVersionPlatform(), 'nt_version' => $meta->getVersionModule(), 'product_pu' => $meta->getPreviewUrlProduct(), 'category_pu' => $meta->getPreviewUrlCategory(), 'search_pu' => $meta->getPreviewUrlSearch(), 'cart_pu' => $meta->getPreviewUrlCart(), 'front_pu' => $meta->getPreviewUrlFront(), 'shop_lang' => strtolower($meta->getLanguageIsoCodeShop()), 'shop_name' => $meta->getShopName(), 'unique_id' => $meta->getUniqueId(), 'fname' => $meta->getFirstName(), 'lname' => $meta->getLastName(), 'email' => $meta->getEmail()), $params));
     if ($account !== null && $account->isConnectedToNosto()) {
         try {
             $url = $account->ssoLogin($meta) . '?' . $queryParams;
         } catch (NostoException $e) {
             // If the SSO fails, we show a "remove account" page to the user in order to
             // allow to remove Nosto and start over.
             // The only case when this should happen is when the api token for some
             // reason is invalid, which is the case when switching between environments.
             $url = NostoHttpRequest::buildUri($this->getBaseUrl() . self::IFRAME_URI_UNINSTALL . '?' . $queryParams, array('{platform}' => $meta->getPlatform()));
         }
     } else {
         $url = NostoHttpRequest::buildUri($this->getBaseUrl() . self::IFRAME_URI_INSTALL . '?' . $queryParams, array('{platform}' => $meta->getPlatform()));
     }
     return $url;
 }