Az ADA rendszerből történő kijelentkezéshez a http://adaserver_domain/ada/v1/logout' url-t kell aktivizálni, egy láthatatlan iframe-be irányitva az outputot.
\ No newline at end of file
+
\ No newline at end of file
diff --git a/adalogin/config.xml b/adalogin/config.xml
new file mode 100644
index 0000000..fb69226
--- /dev/null
+++ b/adalogin/config.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/adalogin/site/adalogin.php b/adalogin/site/adalogin.php
index e5256f9..f48ccee 100644
--- a/adalogin/site/adalogin.php
+++ b/adalogin/site/adalogin.php
@@ -6,15 +6,7 @@
* @license #GNU/GPL
*/
-// ADA server callback
-// ===================
-if (isset($_GET['code'])) {
- include 'index.php';
- exit();
-}
-
-// call from joomla
-// ================
+//--No direct access
defined('_JEXEC') or die('=;)');
// DS has removed from J 3.0
if(!defined('DS')) {
diff --git a/adalogin/site/assets/adalogin.js b/adalogin/site/assets/adalogin.js
new file mode 100644
index 0000000..a25c292
--- /dev/null
+++ b/adalogin/site/assets/adalogin.js
@@ -0,0 +1,45 @@
+
+/**
+ * Adatom.hu kijelentkezés AJAX lekérdezéssel
+ */
+function doAdaLogout() {
+ document.getElementById("errorNotLoggedIn").style.display = "none";
+ document.getElementById("errorParse").style.display = "none";
+ document.getElementById("errorHost").style.display = "none";
+
+ var xhttp;
+ if (window.XMLHttpRequest) {
+ xhttp = new XMLHttpRequest();
+ } else {
+ xhttp = new ActiveXObject("Microsoft.XMLHTTP");
+ }
+ xhttp.onreadystatechange = function() {
+ if (this.readyState == 4) {
+ if (this.status == 200) {
+ var result;
+ try {
+ result = JSON.parse(this.responseText);
+ if (typeof result.message !== undefined) {
+ document.getElementById("adalogout").disabled = true;
+ document.getElementById("logoutDone").style.display = "block";
+ } else {
+ for (var i in result.errors) {
+ if (result.errors[i] == "not logged in") {
+ console.error("You're not logged in!");
+ document.getElementById("errorNotLoggedIn").style.display = "block";
+ }
+ }
+ }
+ } catch(e) {
+ console.error(e);
+ document.getElementById("errorParse").style.display = "block";
+ }
+ } else {
+ console.error("Host unreachable (code: "+this.status+")");
+ document.getElementById("errorHost").style.display = "block";
+ }
+ }
+ };
+ xhttp.open("GET", "https://adatom.hu/ada/v1/logout", true);
+ xhttp.send();
+}
diff --git a/adalogin/site/controller.php b/adalogin/site/controller.php
index 4ddc2b1..8080740 100644
--- a/adalogin/site/controller.php
+++ b/adalogin/site/controller.php
@@ -7,7 +7,6 @@
* @license #GNU/GPL
*
* ADA authoraze service integarttion
-* 2016.12.15 extradata kezelés. a registform -on "extrafields[filename]" nevü extra mezők lehetnek.
*/
// no direct access
@@ -99,10 +98,7 @@ public function dologin() {
$view->setModel($model,true);
$user = $model->getUser($adaid, $adaemail);
if ($user->id > 0) {
- if ($assurance != $user->getParam('ASSURANCE')) {
- $user->setParam('ASSURANCE',$assurance);
- $user->save();
- }
+ $model->setUserAssurances($user, $assurance);
// login to joomla
if ($model->loginToJoomla($adaid, $adaemail)) {
// goto $redi
@@ -115,10 +111,24 @@ public function dologin() {
$this->displayRegistForm($view, $adaid, $adaemail, $assurance, $redi);
}
} // dologin
+
+ /**
+ * process logout
+ */
+ public function dologout() {
+ $app = JFactory::getApplication();
+ $app->logout();
+
+ $document = JFactory::getDocument();
+ $view = $this->getView($this->_viewname, $document->getType());
+ $model = &$this->getModel($this->_mainmodel);
+ $view->setModel($model,true);
+ $view->setLayout('logout');
+ $view->display();
+ }
/**
- * process registform adaid, adaemail, nick, assurance, redi , extrafields(array), CSRF_token data
- * from from. caller: components/com_adalogin/index.php
+ * process registform adaid, adaemail, nick, assurance, redi , CSRF_token data from components/com_adalogin/index.php
*/
public function processform() {
$input = JFactory::getApplication()->input;
@@ -128,7 +138,6 @@ public function processform() {
$redi = base64_decode($input->get('redi','','string'));
if ($redi == '') $redi = JURI::base();
$nick = $input->get('nick');
- $extrafields = $input->get('extrafields',array(),'array');
$document = JFactory::getDocument();
$viewType = $document->getType();
$view = $this->getView($this->_viewname,$viewType);
@@ -137,14 +146,10 @@ public function processform() {
$model->set('PSW',$ada->joomla_psw);
$view->setModel($model,true);
if ($model->checkNewNick($nick)) {
- if ($model->save($adaid, $nick, $adaemail, $assurance, $extrafields)) {
+ if ($model->save($adaid, $nick, $adaemail, $assurance)) {
// login to joomla
if ($model->loginToJoomla($adaid, $adaemail)) {
- $user = JFactory::getUser();
- if ($assurance != $user->getParam('ASSURANCE')) {
- $user->setParam('ASSURANCE',$assurance);
- $user->save();
- }
+ $model->setUserAssurances($user, $assurance);
// goto $redi
$this->setRedirect($redi);
$this->redirect();
@@ -160,30 +165,5 @@ public function processform() {
$this->displayRegistForm($view, $adaid, $adaemail, $assurance, $redi);
}
} // processform
-
- /**
- * logout - task loogout from joomla and from ADA
- */
- public function logout() {
- $app = JFactory::getApplication();
- $app->logout();
- $view = $this->getView($this->_viewname,'html');
- $view->setLayout('logout');
- $view->display();
- }
-
- /**
- * Kilépés az ADA rendszerböl
- */
- public function adalogout() {
- echo '
-
-
- ';
- $view = $this->getView($this->_viewname,'html');
- $view->setLayout('adalogout');
- $view->display();
- }
-
}// class
?>
\ No newline at end of file
diff --git a/adalogin/site/index.php b/adalogin/site/index.php
index 6273dc8..8c30930 100644
--- a/adalogin/site/index.php
+++ b/adalogin/site/index.php
@@ -18,16 +18,12 @@
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
require_once ( JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'factory.php' );
require_once ( JPATH_BASE .DS.'components'.DS.'com_adalogin'.DS.'models'.DS.'ada_obj.php');
-
-
JDEBUG ? $_PROFILER->mark( 'afterLoad' ) : null;
$mainframe = JFactory::getApplication('site');
$mainframe->initialise();
jimport('joomla.plugin.helper');
jimport('joomla.user.helper');
$input = JFactory::getApplication()->input;
-$language = JFactory::getLanguage();
-$language->load('com_adalogin', JPATH_SITE, null, true).' ';
// process code
if ($input->get('code','','string')) {
diff --git a/adalogin/site/langauge b/adalogin/site/langauge
new file mode 100644
index 0000000..0b46a9b
--- /dev/null
+++ b/adalogin/site/langauge
@@ -0,0 +1,15 @@
+ADALOGIN_REDI="Átirányitás URI sikeres belépés után"
+ADALOGIN_REDI_DESC="A sikeres belépés után erre az oldalra kerül a felhasználó"
+ADALOGIN_ADA_ID="ADA azonosító"
+ADALOGIN_ADA_EMAIL="ADA e-mail"
+ADALOGIN_NICKHELP="Most választania kell egy 'álnevet' amivel a Joomla rendszerben Ön azonosítva lesz. A többi felhasználó ezen a néven fogja Önt ismerni. természetesen valódi nevét is használhatja. Avatar képet a gravar.com oldalon tölthet fel, az itt látható e-mail címet kell használnia."
+ADALOGIN_JOOMLA_NICK="Álnév"
+ADALOGIN_OK="Tárolás"
+ADALOGIN_JOOMLA_LOGIN_ERROR="Hiba lépett fel a bejelentkezési folyamatban"
+ADALOGIN_NICK_USED="Ez az 'álnév' már foglalt. Válasszon másikat"
+ADALOGIN_ERROR="Hiba lépett fel"
+ADALOGIN_NICK_REQUED="'Álnevet' meg kell adni."
+ADALOGIN_LOGOUTMSG="Kijelentkezett erről a web oldalról. Az ADA rendszerben azonban továbbra is bejeltkezve marad. Ha onnan is ki akar jelentkezni használja az alábbi linket!"
+ADALOGIN_ADALOGOUT="Kijelentkezés az ADA rendszerböl"
+ADALOGIN_ADALOGOUTMSG="Kijelentkezett az ADA rendszerből"
+
diff --git a/adalogin/site/models/ada_obj.php b/adalogin/site/models/ada_obj.php
index e8e7582..8d7d4ef 100644
--- a/adalogin/site/models/ada_obj.php
+++ b/adalogin/site/models/ada_obj.php
@@ -8,6 +8,29 @@
*/
+
+class JoomlaInterface {
+ public function remoteCall($url,$method,$data,$extraHeader='') {
+ $result = '';
+ if ($extraHeader != '') {
+ $extraHeader .= "\r\n";
+ }
+ $options = array(
+ 'http' => array(
+ 'header' => "Content-type: application/x-www-form-urlencoded\r\n".$extraHeader,
+ 'method'=> $method,
+ 'content' => http_build_query($data)
+ )
+ );
+ $context = stream_context_create($options);
+ return file_get_contents($url, false, $context);
+ return $result;
+ }
+}
+
+global $theJoomlaInterface;
+$theJoomlaInterface = new JoomlaInterface();
+
class AdaloginModelAda_obj {
public $joomla_psw;
@@ -18,8 +41,16 @@ class AdaloginModelAda_obj {
protected $secret;
protected $myURI;
protected $home;
+ protected $interface;
- function __construct() {
+ function __construct($iface = false) {
+ global $theJoomlaInterface;
+ if($iface)
+ {
+ $this->interface = $iface;
+ } else {
+ $this->interface = $theJoomlaInterface;
+ }
$db = JFactory::getDBO();
$db->setQuery('select * from #__adalogin order by id limit 1');
$res = $db->loadObject();
@@ -29,19 +60,17 @@ function __construct() {
$this->myURI = 'https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$i = strpos($this->myURI,'?');
if ($i > 0) $this->myURI = substr($this->myURI,0,$i);
- // https is wrong $this->home = str_replace('/components/com_adalogin','','https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
$this->home = str_replace('/components/com_adalogin','','https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
$i = strpos($this->home,'?');
if ($i > 0) $this->home = substr($this->home,0,$i);
- //$this->home = str_replace('/ssologin','',$this->home); // for old ssologin interface enviroment
- //$this->home = str_replace('/adalogin','',$this->home); // for old adalogin interface enviroment
+ $this->home = str_replace('/ssologin','',$this->home); // for old ssologin interface enviroment
+ $this->home = str_replace('/adalogin','',$this->home); // for old adalogin interface enviroment
}
/**
* redirect ADA server, get loginform. Call this method only in joomla component.controller
*/
public function getLoginURI($redi='') {
-
$redirectURI = JURI::base().'components/com_adalogin/index.php';
// $redirectURI = JURI::base().'ssologin/index.php'; uncomment this line in old ssologin enviroment
// $redirectURI = JURI::base().'adalogin/index.php'; uncomment this line in old adalogin enviroment
@@ -60,25 +89,7 @@ public function getLoginURI($redi='') {
* @return string
*/
public function remoteCall($url,$method,$data,$extraHeader='') {
- $result = '';
- if ($extraHeader != '') {
- $extraHeader .= "\r\n";
- }
- $options = array(
- 'http' => array(
- 'header' => "Content-type: application/x-www-form-urlencoded\r\n".$extraHeader,
- 'method'=> $method,
- 'content' => http_build_query($data)
- )
- );
- if (_UNITTEST == 1) {
- global $testData;
- $result = $testData->getRemoteResult();
- } else {
- $context = stream_context_create($options);
- $result = file_get_contents($url, false, $context);
- }
- return $result;
+ return $this->interface->remoteCall($url,$method,$data,$extraHeader);
}
/**
@@ -139,8 +150,6 @@ protected function getADAuserData($token) {
public function callback() {
$input = JFactory::getApplication()->input;
$db = JFactory::getDBO();
- $session = JFactory::getSession();
-
$token = $this->getADAtoken($input->get('code'));
// get user data
if (isset($token->access_token)) {
@@ -152,6 +161,7 @@ public function callback() {
//$this->home = str_replace('https:','http:',$this->home); //uncomment if https: not supported
if (isset($userData->userid)) {
+ $session = JFactory::getSession();
echo '
ADA login client ...
@@ -167,19 +177,17 @@ public function callback() {
diff --git a/adalogin/site/models/adalogin.php b/adalogin/site/models/adalogin.php
index 0537b9b..6aa7210 100644
--- a/adalogin/site/models/adalogin.php
+++ b/adalogin/site/models/adalogin.php
@@ -125,7 +125,20 @@ public function loginToJoomla($adaid, $adaemail) {
$result = JFactory::getApplication()->login($credentials);
if ($result == false) $this->setError('Error in Joomla login');
return $result;
- }
-
+ }
+ /**
+ * user assurance tárolása a joomla adatbázisba
+ * @param JUser
+ * @param string assurance
+ * return void
+ */
+ public function setUserAssurances($user, $assurance) {
+ if (is_object($user)) {
+ if ($assurance != $user->getParam('ASSURANCE')) {
+ $user->setParam('ASSURANCE',$assurance);
+ $user->save();
+ }
+ }
+ }
}
?>
\ No newline at end of file
diff --git a/adalogin/site/views/adalogin/tmpl/logoutform.php b/adalogin/site/views/adalogin/tmpl/logoutform.php
new file mode 100644
index 0000000..6fedef9
--- /dev/null
+++ b/adalogin/site/views/adalogin/tmpl/logoutform.php
@@ -0,0 +1,13 @@
+