/** * @param string $username * @param ESBResult $esbResult * @return array */ public static function readCall( $username, $esbResult ) { $countryOfRegistration = self::getCountryOfRegistration(); $params = eZINI::instance('merck.ini')->variable( 'EsbSettings', 'AvailableParams' ); if ( !isset( $params ) || !is_array( $params ) ) { MMUserLogin::logError( $username, null, $esbResult->toTicket(), 'Missing esb login parameters. Check merck.ini configuration.' ); return; } if( !in_array( 'Registration_date', $params ) && SolrSafeOperatorHelper::featureIsActive( 'GoogleAnalytics' ) ) { $params[] = 'Registration_date'; } // List of needed profile information $readParameters = array( 'Data' => array( 'Username' => $username, 'Params' => $params ), 'cr' => $countryOfRegistration ); // Fires a request to get user profile data return WSHelper::call( "read", $readParameters ); }
public function relog() { $uuid = isset( $this->_input['uuid'] ) ? $this->_input['uuid'] : null; //$h = isset( $_COOKIE['h'] ) ? $_COOKIE['h'] : null; $h = isset( $this->_input['h'] ) ? $this->_input['h'] : null; $context = isset( $this->_input['context'] ) ? $this->_input['context'] : ContextTool::instance()->domain().'/'; //delete session id cookie //unset($_COOKIE['h']); if ( is_null( $uuid ) || is_null( $h ) ) { MMUserLogin::logError( $uuid, null, null, 'Empty uuid or hash given on Relog' ); return $this->relogError(); } if ( $h != sha1( eZINI::instance( 'merck.ini' )->variable( 'TicketLogin', 'DESKey' ) . $uuid ) ) { MMUserLogin::logError( $uuid, null, null, 'Invalid hash given on Relog' ); return $this->relogError(); } UserLog::instance()->action( 'rememberme' )->uuid( $uuid )->step( 'received' )->store(); $esbResult = new ESBResult(); if ( !SolrSafeOperatorHelper::featureIsActive('UUMP') ) { $datas = static::readCall( $uuid, $esbResult ); } else { $readService = ESBFactory::getUserService(); $parameters = $readService->getFormParameters($uuid); $datas = $readService->read( $parameters, $uuid ); } $isPopulated = static::populateESBResult( $esbResult, $datas ); $this->_esbResult = $esbResult; if ( !$isPopulated ) { // error log caught on WS stack return $this->relogError(); } $esbResult->login = ( $esbResult->userId === $uuid ); if ( !$isPopulated ) { // error log caught on WS stack return $this->relogError(); } $loginResult = MMUserLogin::esbLogin( $uuid, $esbResult, true, $context ); if ( $loginResult ) { $this->_isLoginSuccessful = true; $this->_destUrl = $loginResult['destUrl']; UserLog::instance() ->uuid( $uuid ) ->esb_status( 'Accepted' ) ->store(); $user = MMUsers::getCurrentUserObject(); $sl = SystemLocale::fetchByClusterAndSystem( ClusterTool::clusterIdentifier(), 'esb_language' ); $customerLanguage = !is_null( $sl ) ? $sl : eZINI::instance()->variable( 'RegionalSettings', 'ContentObjectLocale' ); if( SolrSafeOperatorHelper::featureIsActive( 'AsynchronousAnalyticsLoginCall' ) && SolrSafeOperatorHelper::feature( 'AsynchronousAnalyticsLoginCall', 'GoogleAnalytics' ) ) { $amq = new ActiveMQManager(); $domains = eZINI::instance( 'merck.ini' )->variable( 'DomainMappingSettings', 'ClusterDomains' ); $domain = isset( $domains[ClusterTool::clusterIdentifier()] ) ? $domains[ClusterTool::clusterIdentifier()] : 'unidentified.univadis.com'; $gasl = SystemLocale::fetchByClusterAndSystem( ClusterTool::clusterIdentifier(), 'ga_visitor_country' ); $gaCountry = !is_null( $gasl ) ? $gasl : $user->attribute( 'country' ); $gaParams = array( 'v' => 1, 'tid' => 'UA-41415675-6', 'uid' => $uuid, 't' => 'event', 'ec' => 'esb', 'ea' => 'login', 'ni' => 1, 'cd1' => $uuid, 'cd2' => 'logged', 'cd7' => $gaCountry, 'dh' => preg_replace( '#^.*?\.#', '', $domain ), ); $gaParams = 'https://ssl.google-analytics.com/collect?' . http_build_query( $gaParams ); $amq->sendMessageToQueue( 'portail.analytics.google', $gaParams ); } // Stringify params $loginResult['params'][AppBarControl::COOKIE_UNORDERED_APPLIST_KEY] = $user->getApplicationList(); $loginResult['params'][MMUsers::COOKIE_KEY] = $user->getMMSettings(); $strParams = json_encode( $loginResult['params'] ); // Encrypts params $encryptedParams = MMUserLogin::encryptText( $strParams ); // Redirect to PHP-ESI $redirectURL = "/loginActions.php?context=" . urlencode( $loginResult['destUrl'] ) . "¶ms=" . urlencode( $encryptedParams ); if ( !MMUsers::checkCookieLaw() && SolrSafeOperatorHelper::feature('CookieLaw', 'Mode') == MMUsers::COOKIE_LAW_ACTIVE_VERSION_KEY) { $cookieLawPage = SolrSafeOperatorHelper::feature( 'CookieLaw', 'CookieLawPage' ); $redirectURL = ( $cookieLawPage ? $cookieLawPage : '/page/cookie-law' ); } // Branding reconsent check, done only if: // 1. feature ToUPPPopin enabled // 2. Always on WEB with this feature // 3. Only on mobile, whne setting showOnMobile is ON. if ( SolrSafeOperatorHelper::featureIsActive( 'ToUPPPopin') && ( !ContextTool::instance()->isMobile() || ( ContextTool::instance()->isMobile() && SolrSafeOperatorHelper::feature('ToUPPPopin','showOnMobile') ) ) ) { $displayReconsent = $this->checkTouPPPopin( $datas ); // if we need to ask user for reconsent ($displayReconsent - taken fromESB response) we decide if we want page below if: // 1. On WEB and useDedicatedPage setting is ON // 2. On mobile and useDedicatedPageMobile setting is ON if ( $displayReconsent && ( ( !ContextTool::instance()->isMobile() && SolrSafeOperatorHelper::feature( 'ToUPPPopin', 'useDedicatedPage' ) ) || ( ContextTool::instance()->isMobile() && SolrSafeOperatorHelper::feature( 'ToUPPPopin', 'useDedicatedPageMobile' ) ) ) ) { CookieTool::destroyCookie( 'displayToUPPPopin' ); CookieTool::destroyCookie( 'displayToUPPPopin', '/', null ); CookieTool::setCookie( 'displayToUPPPage', 1, time() + ( 2 * 24 * 60 * 60 ) ); $touPpPageUrl = eZINI::instance( 'site.ini' )->variable( 'SiteSettings', 'ToUPPPageUrl' ) . "/#?tpc=" . urlencode( $loginResult['destUrl'] ); $redirectURL = "/loginActions.php?context=" . urlencode( $touPpPageUrl ) . "¶ms=" . urlencode( $encryptedParams ); } } $this->response( $redirectURL ); } }