DMXzone Security Provider PHP Support Product Page

Answered

Redirect to Previous page after login... or pass the variable

Asked 13 Oct 2017 14:20:53
1
has this question
13 Oct 2017 14:20:53 Reinhardt Ellis posted:
Redirect to Previous page after login... or pass the variable...

How do one set go to previous URL....

example of what i want to achieve...
I have a page called .... documents.php that is protected
Now I want to access a document on the page via a ID that is passed... eg... documents.php?id=1
That page is protected by the security enforcer....


<?php
require('dmxConnectLib/dmxConnect.php');

$app = new \lib\App();

$app->exec(<<<'JSON'
{
	"steps": [
		"Connections/cms_system",
		"SecurityProviders/simple_user",
		{
			"module": "auth",
			"action": "restrict",
			"options": {"loginUrl":  "login.php", "forbiddenUrl": "login.php", "provider": "simple_user"}
		}
	]
}
JSON
, TRUE);
?>


So when I do login via the login page how to I go back for the page to use the referrer.....

I have tried to pass the ID to the "security enforcer" code.. but clearly you cant pass PHP in the JSON... any advice would be great..
I have created a $passid var...

<?php
require('dmxConnectLib/dmxConnect.php');

$passid = $_GET['id'];

$app = new \lib\App();

$app->exec(<<<'JSON'
{
	"steps": [
		"Connections/cms_system",
		"SecurityProviders/simple_user",
		{
			"module": "auth",
			"action": "restrict",
			"options": {"loginUrl":  "login.php?id="'$passid', "forbiddenUrl": "login.php?id="'$passid', "provider": "simple_user"}
		}
	]
}
JSON
, TRUE);
?>


any suggestions how this can be done...

As a reference im going to bring up Dreamweaver authentication code... this is what im after

Login page...with the redirect if success ... option selected...

....
 if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
    }
...



on the protect code page

.....
 $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
  $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
...





Replies

Replied 16 Oct 2017 08:04:45
16 Oct 2017 08:04:45 Teodor Kuduschiev replied:
Hello Reinhardt,
Unfortunately there is no such an option in security provider yet. I will check if this can be added in the future updates.
Replied 16 Oct 2017 08:12:40
16 Oct 2017 08:12:40 Reinhardt Ellis replied:
Hi Teodor... Thank you for the quick response....

Is there no "manual" work around? as i then need to use the old "Dreamweaver behaviors" ... last thing i want to do... as it then defeats the complete point of having APP CONNECT.....

Replied 13 Nov 2017 13:01:45
13 Nov 2017 13:01:45 Reinhardt Ellis replied:
Hi Teodor .. any idea.. when there will be some sort of an update on this... i know you have billions on things to do... and my request is not "important" but i really do need a work around.. .. any possible "manual" coding to do this please.... could you please maybe ask the "developer" of this "extension" for a temp solution please..
Replied 13 Nov 2017 13:15:18
13 Nov 2017 13:15:18 Teodor Kuduschiev replied:
Hello Reinhardt,
There is a manual workaround, using some handcoding.
First - on the inner page (the page restricted with the security enforcer, just add this:

$_SESSION['myid'] = isset($_GET['id']) ? $_GET['id'] : '';

like:


Then on the login page, for the log in server action onsuccess add got to url and use:

'inner_page.php?id='+<?php echo isset($_SESSION['myid']) ? $_SESSION['myid'] : '';?>

like:


This should do the job for you.


Replied 13 Nov 2017 13:21:41
13 Nov 2017 13:21:41 Reinhardt Ellis replied:
thank you Teodor for the response.. i really appreciate this ...

** the solution above worked like a charm.. Just remember (* for the users on this forum) to place this at the top of your **login** page ...

<?php session_start(); ?>

Reply to this topic