needsOtp = 'false'; $response->form = ""; // Session check if (JSession::checkToken('POST')) { $db = JFactory::getDbo(); // Check if TFA is enabled. If not, just return false $query = $db->getQuery(true) ->select('COUNT(*)') ->from('#__extensions') ->where('enabled=' . $db->q(1)) ->where('folder=' . $db->q('twofactorauth')); $db->setQuery($query); $tfaCount = $db->loadResult(); if ($tfaCount > 0) { $username = JRequest::getVar('u', '', 'POST', 'username'); $query = $db->getQuery(true) ->select('id, password, otpKey') ->from('#__users') ->where('username=' . $db->q($username)); $db->setQuery($query); $result = $db->loadObject(); if ($result && $result->otpKey != '') { //jimport('sourcecoast.utilities'); //SCStringUtilities::loadLanguage('mod_sclogin'); JFactory::getLanguage()->load('mod_sclogin'); //$password = JRequest::getString('p', '', 'POST', JREQUEST_ALLOWRAW); //if (JUserHelper::verifyPassword($password, $result->password, $result->id)) //{ $response->needsOtp = 'true'; ob_start(); require(JModuleHelper::getLayoutPath('mod_sclogin', 'otp')); $response->form = ob_get_clean(); //} } } } echo json_encode($response); exit; } } // Instantiate the application object, passing the class name to JCli::getInstance // and use chaining to execute the application. $app = JApplicationWeb::getInstance('SourcecoastTfaCheckWeb'); // Loading the 'site' application to make sure our session (and other) data is from the 'site'.. sounds obvious, but documenting it, because it won't be the next time I look at this. JFactory::getApplication('site'); $app->execute();