mirror of
https://github.com/til-schneider/slim-wiki.git
synced 2025-08-04 15:47:33 +02:00
Fixed: Saving editor caused error if editing a page of a subdirectory while the password was only entered for that subdirectory (and not on root level)
This commit is contained in:
@@ -49,6 +49,9 @@ class Main {
|
|||||||
try {
|
try {
|
||||||
$responseData['result'] = call_user_func_array(array($object, $methodName), $requestData['params']);
|
$responseData['result'] = call_user_func_array(array($object, $methodName), $requestData['params']);
|
||||||
} catch (Exception $exc) {
|
} catch (Exception $exc) {
|
||||||
|
if ($exc->getMessage() == 'Not logged in') {
|
||||||
|
$this->setUnauthorizedHeaders();
|
||||||
|
}
|
||||||
$msg = "Calling RPC $objectName.$methodName failed: " . $exc->getMessage();
|
$msg = "Calling RPC $objectName.$methodName failed: " . $exc->getMessage();
|
||||||
error_log($msg);
|
error_log($msg);
|
||||||
$responseData['error'] = array( 'code' => -32000, 'message' => $msg );
|
$responseData['error'] = array( 'code' => -32000, 'message' => $msg );
|
||||||
@@ -78,9 +81,7 @@ class Main {
|
|||||||
if ($mode == 'edit' && ! $config['demoMode']) {
|
if ($mode == 'edit' && ! $config['demoMode']) {
|
||||||
$loginState = $this->context->getEditorService()->getLoginState();
|
$loginState = $this->context->getEditorService()->getLoginState();
|
||||||
if ($loginState != 'logged-in') {
|
if ($loginState != 'logged-in') {
|
||||||
$wikiName = $this->context->getConfig()['wikiName'];
|
$this->setUnauthorizedHeaders();
|
||||||
header('WWW-Authenticate: Basic realm="'.$wikiName.'"');
|
|
||||||
header('HTTP/1.0 401 Unauthorized');
|
|
||||||
|
|
||||||
$mode = 'view';
|
$mode = 'view';
|
||||||
$showCreateUserButton = true;
|
$showCreateUserButton = true;
|
||||||
@@ -150,6 +151,12 @@ class Main {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function setUnauthorizedHeaders() {
|
||||||
|
$wikiName = $this->context->getConfig()['wikiName'];
|
||||||
|
header('WWW-Authenticate: Basic realm="'.$wikiName.'"');
|
||||||
|
header('HTTP/1.0 401 Unauthorized');
|
||||||
|
}
|
||||||
|
|
||||||
private function isUserDefined() {
|
private function isUserDefined() {
|
||||||
$config = $this->context->getConfig();
|
$config = $this->context->getConfig();
|
||||||
foreach ($config as $key => $value) {
|
foreach ($config as $key => $value) {
|
||||||
|
Reference in New Issue
Block a user