mirror of
https://github.com/processwire/processwire.git
synced 2025-08-18 20:41:16 +02:00
Fix issue processwire/processwire-issues#1527
This commit is contained in:
@@ -434,12 +434,12 @@ class PagesRequest extends Wire {
|
||||
|
||||
if($page->id) {
|
||||
$page = $this->checkAccess($page, $user);
|
||||
if(!$page || !$page->id) {
|
||||
// 404
|
||||
$page = $this->pages->newNullPage();
|
||||
} if(is_string($page)) {
|
||||
if(is_string($page)) {
|
||||
// redirect URL
|
||||
$this->setRedirectUrl($page);
|
||||
if(strlen($page)) $this->setRedirectUrl($page, 302);
|
||||
$page = $this->pages->newNullPage();
|
||||
} else if(!$page || !$page->id) {
|
||||
// 404
|
||||
$page = $this->pages->newNullPage();
|
||||
} else {
|
||||
// login Page or Page to render
|
||||
@@ -734,6 +734,18 @@ class PagesRequest extends Wire {
|
||||
} else if(strlen($redirectLogin)) {
|
||||
// redirect URL provided in template.redirectLogin
|
||||
$redirectUrl = str_replace('{id}', $page->id, $redirectLogin);
|
||||
list($path, $query) = array($redirectUrl, '');
|
||||
if(strpos($redirectUrl, '?') !== false) list($path, $query) = explode('?', $redirectUrl, 2);
|
||||
if(strlen($path) && strpos($path, '/') === 0 && strpos($path, '//') === false) {
|
||||
// attempt to match to page so we can use URL with scheme and relative to installation url
|
||||
$p = $this->wire()->pages->get($path);
|
||||
if($p->id && $p->viewable()) {
|
||||
$redirectUrl = $p->httpUrl() . ($query ? "?$query" : "");
|
||||
}
|
||||
} else if(strpos($path, '//') === 0 && strpos($path, '://') === false) {
|
||||
// double slash at beginning force path without checking if it maps to page
|
||||
$redirectUrl = '/' . ltrim($redirectUrl, '/');
|
||||
}
|
||||
return $redirectUrl;
|
||||
}
|
||||
|
||||
|
@@ -149,10 +149,11 @@ class ProcessPageView extends Process {
|
||||
$code = $request->getResponseCode();
|
||||
|
||||
if($code == 401 || $code == 403) {
|
||||
$this->userNotAllowed($user, $page, $request);
|
||||
$this->userNotAllowed($user, $originalPage, $request);
|
||||
}
|
||||
|
||||
if(!$page || !$page->id || $originalPage->id == $config->http404PageID) {
|
||||
$this->checkForRedirect($request);
|
||||
$s = 'access not allowed';
|
||||
$e = new Wire404Exception($s, Wire404Exception::codePermission);
|
||||
return $this->pageNotFound($originalPage, $request->getRequestPath(), true, $s, $e);
|
||||
|
Reference in New Issue
Block a user