components/com_user/controller.php

function login() {

// Check for request forgeries $mobilelogin = JRequest::getVar(‘mobilelogin’, ”, ‘get’, ‘mobilelogin’);

$callback = JRequest::getVar(‘callback’, ”, ‘get’, ‘callback’); if($mobilelogin != “1”)

{

JRequest::checkToken(‘request’) or jexit( ‘Invalid Token’ ); }else { $_POST = $_GET; }
global $mainframe;
if ($return = JRequest::getVar(‘return’, ”, ‘method’, ‘base64’)) { $return = base64_decode($return); if (!JURI::isInternal($return)) { $return = ”; } }
$options = array(); $options[‘remember’] = JRequest::getBool(‘remember’, false); $options[‘return’] = $return;
$credentials = array(); $credentials[‘username’] = JRequest::getVar(‘username’, ”, ‘method’, ‘username’); $credentials[‘password’] = JRequest::getString(‘passwd’, ”, ‘post’, JREQUEST_ALLOWRAW);
//preform the login action $error = $mainframe->login($credentials, $options); if(!JError::isError($error)) { // Redirect if the return url is not registration or login if ( ! $return ) { $return = ‘index.php?option=com_user’; } if(!$this->validate_userbrands()) { $return = “index.php?option=com_php&Itemid=94”; }else { $return = “index.php?option=com_community&view=profile&task=edit&Itemid=28″; } //$return = $return.”&task=edit”; //$mainframe->redirect( “index.php?option=com_community&view=profile&task=edit&Itemid=28” ); if($mobilelogin != “1”) { $mainframe->redirect( $return ); }else { $output = array(‘Success’ => ‘True’); if ($callback) { header(‘Content-Type: text/javascript’); echo $callback . ‘(‘ . json_encode($output) . ‘);’; } else { header(‘Content-Type: application/x-json’); echo json_encode($output); } die;
} } else { // Facilitate third party login forms if ( ! $return ) { $return = ‘index.php?option=com_user&view=login’; } if($mobilelogin != “1”) { // Redirect to a login form $mainframe->redirect( $return ); } else { $output = array(‘Success’ => ‘False’); if ($callback) { header(‘Content-Type: text/javascript’); echo $callback . ‘(‘ . json_encode($output) . ‘);’; } else { header(‘Content-Type: application/x-json’); echo json_encode($output); } die; }
} }