function login($epUserdata = null) { $credentials = array(); $options = array(); if ($epUserdata == null) { // Check for request forgeries //JRequest::checkToken('request') or jexit( 'Invalid Token' ); $credentials['provider'] = JRequest::getVar('provider', null, 'method', 'string'); $credentials['username'] = JRequest::getVar('username', '', 'method', 'username'); $credentials['userid'] = JRequest::getInt('userid', '0', 'method'); $credentials['session'] = JRequest::getVar('session', '', 'method', 'string'); $credentials['oauth_token'] = JRequest::getVar('oauth_token', '', 'method', 'string'); } else { $credentials['provider'] = $epUserdata['epprovider']; $credentials['username'] = $epUserdata['epusername']; $options['userid'] = $epUserdata['userid']; } $credentials['provider'] = trim($credentials['provider']); $credentials['username'] = trim($credentials['username']); global $mainframe; $user =& JFactory::getUser(); $registerNewAlias = !$user->guest; if ($return = JRequest::getVar('return', '', 'method', 'base64')) { $return = base64_decode($return); if (!JURI::isInternal($return)) { $return = ''; } } $options['remember'] = JRequest::getBool('remember', false); $options['return'] = $return; $credentials['password'] = JRequest::getString('password', '', 'post', JREQUEST_ALLOWRAW); # agregado por G2P $options['providerid'] = JRequest::getInt('providerid', '0', 'method'); $options['externalid'] = JRequest::getVar('externalid', '', 'method', 'string'); $options['email'] = JRequest::getVar('email', '', 'method', 'string'); $options['label'] = JRequest::getVar('label', '', 'method', 'string'); ##### testing ########## $db =& JFactory::getDBO(); //preform the login action $error = $mainframe->login($credentials, $options); $this->endAuthentication(); if (!JError::isError($error)) { // Redirect if the return url is not registration or login if (!$return) { $return = 'index.php?option=com_user'; } if ($credentials['userid'] == 0) { $this->aliasreg($options['providerid'], $options['externalid'], $options['label'], $options['email']); } else { try { $session =& JFactory::getSession(); $selectProvider = 'select p.id from #__providers p where p.name = "' . $credentials['provider'] . '"'; $db->setQuery($selectProvider); $dbprovider = $db->loadObject(); $this->insertAlias(0, $credentials['userid'], $session->get('externalidentifier'), $dbprovider->id, $session->get('label'), $session->get('email')); } catch (Exception $ex) { $message = JText::_("SYSTEM_ALIAS_REGISTERED"); UserHelper::showMessage(ERROR, $message); } } $zonal = UserHelper::getUsersZonal(); require_once JPATH_ROOT . DS . 'components' . DS . 'com_zonales' . DS . 'helper.php'; comZonalesHelper::setZonal($zonal); $i18nKey = $registerNewAlias ? 'SYSTEM_MESSAGE_SUCCESS_ALIAS_ADDED' : 'SYSTEM_MESSAGE_SUCCESS_LOGIN'; $message = JText::_($i18nKey); UserHelper::showMessage(SUCCESS, $message); } else { $i18nKey = $registerNewAlias ? 'SYSTEM_MESSAGE_ERROR_ALIAS_NOT_ADDED' : 'SYSTEM_MESSAGE_ERROR_LOGIN'; $message = JText::_($i18nKey); UserHelper::showMessage(ERROR, $message); } }