#342 redirect to old location on login if forced logout

This commit is contained in:
Ulf Gebhardt 2017-07-26 12:55:15 +02:00
parent 145abe460f
commit 50daf11ef3
3 changed files with 30 additions and 9 deletions

View File

@ -7,7 +7,13 @@ function init_saimod_sys_login() {
system.account_login($('#bt_login_user').val(),$('#bt_login_password').val(),function(data){
if(data.status){
$('.help-block').html("Login successfull.</br>");
location.reload(true);
var redirect = getParameterByName('redirect');
if(redirect){
location.href = location.protocol + '//' + location.host + location.pathname+'#!'+JSON.parse(redirect);
//system.load();
} else {
location.reload(true);
}
} else {
$('.help-block').html("Login not successfull.</br> User & Password combination wrong.");
}

View File

@ -1,3 +1,13 @@
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
function init_saistart_sys_sai() {
// Set all Panels the same height
$(".inner-page").height(Math.max.apply(null, $(".inner-page").map(function(){return $(this).height();}).get()));
@ -9,7 +19,13 @@ function init_saistart_sys_sai() {
system.account_login($('#bt_login_user').val(),$('#bt_login_password').val(),function(data){
if(data.status){
$('.help-block').html("Login successfull.</br>");
location.reload(true);
var redirect = getParameterByName('redirect');
if(redirect){
location.href = location.protocol + '//' + location.host + location.pathname+'#!'+JSON.parse(redirect);
//system.load();
} else {
location.reload(true);
}
} else {
$('.help-block').html("Login not successfull.</br> User & Password combination wrong.");
}

View File

@ -26,21 +26,20 @@ class saigui {
public function html(){
\SYSTEM\SECURITY\security::isLoggedIn(); // refresh session
//Direct JSON Input
$pg = json_decode(file_get_contents("php://input"), true);
if(!$pg){
$pg = array_merge($_POST,$_GET);}
//$pg = json_decode(file_get_contents("php://input"), true);
//if(!$pg){
$pg = array_merge($_POST,$_GET);//}
if(isset($pg[self::SAI_MOD_POSTFIELD])){
$classname = \str_replace('.', '\\', $pg[self::SAI_MOD_POSTFIELD]);
$pg[self::SAI_MOD_POSTFIELD] = \str_replace('.', '_', $pg[self::SAI_MOD_POSTFIELD]);
$mods = \SYSTEM\SAI\sai::getAllModules();
if( $classname &&
\array_search($classname, $mods) !== false &&
\array_search($classname, \SYSTEM\SAI\sai::getAllModules()) !== false &&
( \call_user_func(array($classname, 'right_public')) ||
\call_user_func(array($classname, 'right_right')))){
return \SYSTEM\API\api::run('\SYSTEM\API\verify', $classname , $pg, 42, true, false);
} else {
return '<meta http-equiv="refresh" content="0; url=./sai.php">You are no longer logged in. Page reload in 5sec...';}
} else {
return '<script type="text/javascript"> window.location = "./sai.php?redirect="+JSON.stringify(system.cur_state());</script>';}
} else {
return \SYSTEM\API\api::run('\SYSTEM\API\verify', '\SYSTEM\SAI\SaiModule', $pg, 42, false, true);}
}