Preserve current url when logging in. Pass the current url as part of the url to the login form
so we can return the user to the starting url after login.
This commit is contained in:
committed by
WineHQ
parent
9d35df1b54
commit
c5e1b08b5d
@@ -209,8 +209,11 @@ function cmd_do_login()
|
|||||||
|
|
||||||
if($iResult == SUCCESS)
|
if($iResult == SUCCESS)
|
||||||
{
|
{
|
||||||
|
$sReturnUrl = $aClean['sReturnTo'];
|
||||||
|
if(!$sReturnUrl)
|
||||||
|
$sReturnUrl = apidb_fullurl("index.php");
|
||||||
addmsg("You are successfully logged in as '$oUser->sRealname'.", "green");
|
addmsg("You are successfully logged in as '$oUser->sRealname'.", "green");
|
||||||
util_redirect_and_exit(apidb_fullurl("index.php"));
|
util_redirect_and_exit($sReturnUrl);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
retry("login","Login failed ".$shNote);
|
retry("login","Login failed ".$shNote);
|
||||||
|
|||||||
@@ -6,7 +6,10 @@ require_once(BASE."include/util.php");
|
|||||||
/**************/
|
/**************/
|
||||||
echo "<div class='default_container'>\n";
|
echo "<div class='default_container'>\n";
|
||||||
echo '<form method="post" name="sFlogin" action="account.php">',"\n";
|
echo '<form method="post" name="sFlogin" action="account.php">',"\n";
|
||||||
echo html_frame_start("Login to Application DB","400","",0)
|
echo html_frame_start("Login to Application DB","400","",0);
|
||||||
|
/* Pass on the URL we should return to after log-in */
|
||||||
|
global $aClean;
|
||||||
|
echo '<input type="hidden" name="sReturnTo" value="'.$aClean['sReturnTo'].'" />';
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!-- start of login form -->
|
<!-- start of login form -->
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ function global_sidebar_login() {
|
|||||||
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
$g->add("Log in", BASE."account.php?sCmd=login");
|
$g->add("Log in", login_url());
|
||||||
$g->add("Register", BASE."account.php?sCmd=new");
|
$g->add("Register", BASE."account.php?sCmd=new");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -903,4 +903,20 @@ function util_trim_description($sDescription)
|
|||||||
return trim(strip_tags($aDesc[0]));
|
return trim(strip_tags($aDesc[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This allows us to pass on the current URL to the login form so that the user is returned
|
||||||
|
to the current page once he has logged in */
|
||||||
|
function login_url()
|
||||||
|
{
|
||||||
|
$sCurrentUrl = $_SERVER['REQUEST_URI'];
|
||||||
|
$sLoginUrl = BASE."account.php?sCmd=login";
|
||||||
|
|
||||||
|
/* If we are on the login page that means the URL already contains an sReturnTo value,
|
||||||
|
and we don't want two. Besides, there is little point in redirecting to the login page
|
||||||
|
after login. */
|
||||||
|
if(!strpos($sCurrentUrl, "sReturnTo") && !strpos($sCurrentUrl, "account.php"))
|
||||||
|
$sLoginUrl .= "&sReturnTo=".$sCurrentUrl;
|
||||||
|
|
||||||
|
return $sLoginUrl;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ if(!$_SESSION['current']->isLoggedIn())
|
|||||||
|
|
||||||
$str_benefits
|
$str_benefits
|
||||||
|
|
||||||
<p>So what are you waiting for, [<a href=\"account.php?sCmd=login\">log in</a>]
|
<p>So what are you waiting for, [<a href=\"".login_url()."\">log in</a>]
|
||||||
or [<a href=\"account.php?sCmd=new\">register</a>] now! Your help in
|
or [<a href=\"account.php?sCmd=new\">register</a>] now! Your help in
|
||||||
stomping out Wine issues will be greatly appreciated.</p>";
|
stomping out Wine issues will be greatly appreciated.</p>";
|
||||||
} else
|
} else
|
||||||
|
|||||||
Reference in New Issue
Block a user