do not redirect if session ended and it is an ajax call

This commit is contained in:
Uwe Steinmann 2016-08-22 17:00:52 +02:00
parent c8121afed1
commit 34ce80eb3d

View File

@ -24,19 +24,25 @@ if (!strncmp("/op", $refer, 3)) {
} else {
$refer = urlencode($refer);
}
/* Check if this is a ajax call. In that case do not redirect to any page */
$isajax = isset($_GET['action']) && ($_GET['action'] != 'show');
if (!isset($_COOKIE["mydms_session"])) {
if($settings->_enableGuestLogin && $settings->_enableGuestAutoLogin) {
require_once("../inc/inc.ClassSession.php");
$session = new SeedDMS_Session($db);
if(!$dms_session = $session->create(array('userid'=>$settings->_guestID, 'theme'=>$settings->_theme, 'lang'=>$settings->_language))) {
header("Location: " . $settings->_httpRoot . "out/out.Login.php?referuri=".$refer);
if(!$isajax)
header("Location: " . $settings->_httpRoot . "out/out.Login.php?referuri=".$refer);
exit;
}
$resArr = $session->load($dms_session);
} elseif($settings->_autoLoginUser) {
require_once("../inc/inc.ClassSession.php");
if(!($user = $dms->getUser($settings->_autoLoginUser))/* || !$user->isGuest()*/) {
header("Location: " . $settings->_httpRoot . "out/out.Login.php?referuri=".$refer);
if(!$isajax)
header("Location: " . $settings->_httpRoot . "out/out.Login.php?referuri=".$refer);
exit;
}
$theme = $user->getTheme();
@ -51,12 +57,14 @@ if (!isset($_COOKIE["mydms_session"])) {
}
$session = new SeedDMS_Session($db);
if(!$dms_session = $session->create(array('userid'=>$user->getID(), 'theme'=>$theme, 'lang'=>$lang))) {
header("Location: " . $settings->_httpRoot . "out/out.Login.php?referuri=".$refer);
if(!$isajax)
header("Location: " . $settings->_httpRoot . "out/out.Login.php?referuri=".$refer);
exit;
}
$resArr = $session->load($dms_session);
} else {
header("Location: " . $settings->_httpRoot . "out/out.Login.php?referuri=".$refer);
if(!$isajax)
header("Location: " . $settings->_httpRoot . "out/out.Login.php?referuri=".$refer);
exit;
}
} else {
@ -65,7 +73,8 @@ if (!isset($_COOKIE["mydms_session"])) {
$session = new SeedDMS_Session($db);
if(!$resArr = $session->load($dms_session)) {
setcookie("mydms_session", $dms_session, time()-3600, $settings->_httpRoot); //delete cookie
header("Location: " . $settings->_httpRoot . "out/out.Login.php?referuri=".$refer);
if(!$isajax)
header("Location: " . $settings->_httpRoot . "out/out.Login.php?referuri=".$refer);
exit;
}
}
@ -77,7 +86,8 @@ $session->updateAccess($dms_session);
$user = $dms->getUser($resArr["userID"]);
if (!is_object($user)) {
setcookie("mydms_session", $dms_session, time()-3600, $settings->_httpRoot); //delete cookie
header("Location: " . $settings->_httpRoot . "out/out.Login.php?referuri=".$refer);
if(!$isajax)
header("Location: " . $settings->_httpRoot . "out/out.Login.php?referuri=".$refer);
exit;
}
@ -126,6 +136,10 @@ if(file_exists($settings->_rootDir . "view/".$theme."/languages/" . $lang . "/la
include $settings->_rootDir . "view/".$theme."/languages/" . $lang . "/lang.inc";
}
/* if this is a ajax call, then exit early as the rest of the script is irrelevant */
if($isajax)
return;
/* Check if password needs to be changed because it expired. If it needs
* to be changed redirect to out/out.ForcePasswordChange.php. Do this
* check only if password expiration is turned on, we are not on the