function AuthJUser() { if (!class_exists('Auth0Connect')) { require_once JPATH_COMPONENT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'auth0_connect.php'; } $params = JComponentHelper::getParams('com_auth0'); $clientid = $params->get('clientid'); $clientsecret = $params->get('clientsecret'); $domain = 'https://' . $params->get('domain'); $this->app = JFactory::getApplication('site'); $code = $this->app->input->getVar('code'); $auth0 = new Auth0Connect($domain, $clientid, $clientsecret, JRoute::_('index.php?option=com_auth0&task=auth', true, -1)); try { $accessToken = $auth0->getAccessToken($code); $userInfo = $auth0->getUserInfo($accessToken); if (($jUser = $this->doesUserExists($userInfo)) !== null) { $this->loginAuth0User($jUser); } else { $this->createAuth0User($userInfo); } $app = JFactory::getApplication(); $app->redirect('/'); } catch (Exception $e) { echo $e; exit; } }
function AuthJUser() { if (!class_exists('Auth0Connect')) { require_once JPATH_COMPONENT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'auth0_connect.php'; } if (!class_exists('Auth0ValidationException')) { require_once JPATH_COMPONENT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'auth0_validation_exception.php'; } $this->app = JFactory::getApplication('site'); $return = $this->getReturn('state', 'RAW'); if (empty($return)) { $return = $this->getReturn('return', 'BASE64'); } if (empty($return)) { $return = 'index.php?option=com_users&view=profile'; } // Set the return URL in the user state to allow modification by plugins $this->app->setUserState('users.login.form.return', $return); $params = JComponentHelper::getParams('com_auth0'); $clientid = $params->get('clientid'); $clientsecret = $params->get('clientsecret'); $domain = 'https://' . $params->get('domain'); $code = $this->app->input->getVar('code'); $auth0 = new Auth0Connect($domain, $clientid, $clientsecret, JRoute::_('index.php?option=com_auth0&task=auth', true, -1)); try { $accessToken = $auth0->getAccessToken($code); $userInfo = $auth0->getUserInfo($accessToken); if (($jUser = $this->doesUserExists($userInfo)) !== null) { $this->loginAuth0User($jUser); } else { if (($jUser = $this->doesUserExistsUnlinked($userInfo)) !== null) { $this->linkAuth0User($jUser, $userInfo); } else { $this->createAuth0User($userInfo); } } $this->app->setUserState('users.login.form.data', array()); $this->app->redirect(JRoute::_($this->app->getUserState('users.login.form.return'), false)); } catch (Auth0ValidationException $e) { $this->app->enqueueMessage($e->getMessage(), 'warning'); $this->app->redirect(JRoute::_('index.php?option=com_users&view=login', false)); } catch (Exception $e) { $this->app->enqueueMessage(JText::sprintf('COM_AUTH0_GENERIC_ERROR'), 'warning'); $this->app->redirect(JRoute::_('index.php?option=com_users&view=login', false)); } }
* @download URL http://www.auth0.com */ defined('_JEXEC') or die('Restricted access'); $document = JFactory::getDocument(); $document->addStyleSheet('components/com_auth0/assets/auth0back.css'); $params = JComponentHelper::getParams('com_auth0'); $clientid = $params->get('clientid'); $clientsecret = $params->get('clientsecret'); $domain = 'https://' . $params->get('domain'); echo '<div class="span10"><div class="well well-small"><ul>'; if (trim($clientid) == "" || trim($clientsecret) == "" || trim($domain) == "") { echo '<li>Auth0 app data: <span style="color:red"><b>Incomplete</b></span></li>'; } else { require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_auth0' . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'auth0_connect.php'; try { $auth0 = new Auth0Connect($domain, $clientid, $clientsecret, JRoute::_('index.php?option=com_auth0&task=auth', true, -1)); $auth0->getToken(); echo '<li>Auth0 app data: <span style="color:green"><b>Complete</b></span></li>'; } catch (Exception $e) { echo '<li>Auth0 app data: <span style="color:red"><b>Invalid credentials</b></span></li>'; } } $db = JFactory::getDBO(); $query = "SELECT published FROM #__modules WHERE module='mod_auth0'"; $db->setQuery($query); $pubdata = $db->loadObject(); if ($pubdata) { echo $pubdata->published == 1 ? '<li>Module : <span style="color:green"><b>Enabled</b></span></li>' : '<li>Module : <span style="color:red"><b>Disabled</b></span> </li>'; } else { echo '<li>Module : <span style="color:red"><b>Not Found</b></span></li>'; }