Merge pull request #640 from jrd288/offer_login
Offer login prompt instead of throwing error
This commit is contained in:
commit
45feac3d36
|
@ -147,7 +147,18 @@ else
|
||||||
Fatal( "View '$view' does not exist" );
|
Fatal( "View '$view' does not exist" );
|
||||||
require_once $includeFile;
|
require_once $includeFile;
|
||||||
}
|
}
|
||||||
|
// If the view overrides $view to 'error', and the user is not logged in, then the
|
||||||
|
// issue is probably resolvable by logging in, so provide the opportunity to do so.
|
||||||
|
// The login view should handle redirecting to the correct location afterward.
|
||||||
|
if ( $view == 'error' && !isset($user) )
|
||||||
|
{
|
||||||
|
$view = 'login';
|
||||||
|
foreach ( getSkinIncludes( 'views/login.php', true, true ) as $includeFile )
|
||||||
|
require_once $includeFile;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// If the view is missing or the view still returned error with the user logged in,
|
||||||
|
// then it is not recoverable.
|
||||||
if ( !$includeFiles || $view == 'error' )
|
if ( !$includeFiles || $view == 'error' )
|
||||||
{
|
{
|
||||||
foreach ( getSkinIncludes( 'views/error.php', true, true ) as $includeFile )
|
foreach ( getSkinIncludes( 'views/error.php', true, true ) as $includeFile )
|
||||||
|
|
|
@ -33,7 +33,7 @@ dist_web_DATA = \
|
||||||
montage.js \
|
montage.js \
|
||||||
montage.js.php \
|
montage.js.php \
|
||||||
options.js.php \
|
options.js.php \
|
||||||
postlogin.js \
|
postlogin.js.php \
|
||||||
state.js \
|
state.js \
|
||||||
state.js.php \
|
state.js.php \
|
||||||
timeline.js \
|
timeline.js \
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
(function () { window.location.replace( thisUrl ); }).delay( 500 );
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
// $thisUrl is the base URL used to access ZoneMinder.
|
||||||
|
//
|
||||||
|
// If the user attempts to access a privileged view but is not logged in, then he may
|
||||||
|
// be given the opportunity to log in via the login view. In that case, the login view
|
||||||
|
// will save the GET request via the postLoginQuery variable. After logging in, this
|
||||||
|
// view receives the postLoginQuery via the login form submission, and we can then
|
||||||
|
// redirect the user to his original intended destination by appending it to the URL.
|
||||||
|
?>
|
||||||
|
|
||||||
|
(
|
||||||
|
function ()
|
||||||
|
{
|
||||||
|
// Append '?(GET query)' to URL if the GET query is not empty.
|
||||||
|
var querySuffix = "<?php
|
||||||
|
if (!empty($_POST["postLoginQuery"]))
|
||||||
|
echo "?".$_POST["postLoginQuery"];
|
||||||
|
?>";
|
||||||
|
|
||||||
|
var newUrl = thisUrl + querySuffix;
|
||||||
|
window.location.replace(newUrl);
|
||||||
|
}
|
||||||
|
).delay( 500 );
|
|
@ -29,6 +29,7 @@ xhtmlHeaders(__FILE__, $SLANG['Login'] );
|
||||||
<form name="loginForm" id="loginForm" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
|
<form name="loginForm" id="loginForm" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
|
||||||
<input type="hidden" name="action" value="login"/>
|
<input type="hidden" name="action" value="login"/>
|
||||||
<input type="hidden" name="view" value="postlogin"/>
|
<input type="hidden" name="view" value="postlogin"/>
|
||||||
|
<input type="hidden" name="postLoginQuery" value="<?php echo $_SERVER['QUERY_STRING'] ?>">
|
||||||
<table id="loginTable" class="minor" cellspacing="0">
|
<table id="loginTable" class="minor" cellspacing="0">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
Loading…
Reference in New Issue