From 819489a7fb17f8e57fe6af7e01c34e9260d4e9ea Mon Sep 17 00:00:00 2001
From: Starbeamrainbowlabs <sbrl@starbeamrainbowlabs.com>
Date: Tue, 3 Jul 2018 11:57:53 +0100
Subject: [PATCH] Bugfix: Correct is logged in check when restoring page
 revisions

---
 build/index.php             | 6 +++---
 module_index.json           | 2 +-
 modules/feature-history.php | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/build/index.php b/build/index.php
index f7a774a..ae54276 100644
--- a/build/index.php
+++ b/build/index.php
@@ -404,7 +404,7 @@ if($settings->sessionprefix == "auto")
 /////////////////////////////////////////////////////////////////////////////
 /** The version of Pepperminty Wiki currently running. */
 $version = "v0.17-dev";
-$commit = "06c2b3886826e915f709df06714c79b3a7a6dd18";
+$commit = "6e7698b4a9210cd3198ee1bd2a117e7bcf162819";
 /// Environment ///
 /** Holds information about the current request environment. */
 $env = new stdClass();
@@ -3322,9 +3322,9 @@ register_module([
 			global $env, $settings, $pageindex;
 			
 			if((!$env->is_admin && $settings->history_revert_require_moderator) ||
-				$env->is_logged_in) {
+				!$env->is_logged_in) {
 				http_response_code(401);
-				exit(page_renderer::render_main("Unauthorised - $settings->sitename", "<p>You can't revert pages to a previous revision because " . ($settings->history_revert_require_moderator && $env->is_logged_in ? "you aren't logged in as a moderator. You can try <a href='?action=logout'>logging out</a> and then" : "you aren't logged in. You can try") . " <a href='?action=login&returnto=" . rawurlencode("?action=history-revert&revision={$env->history->revision_number}&page=" . rawurlencode($env->page)) . "logging in</a>."));
+				exit(page_renderer::render_main("Unauthorised - $settings->sitename", "<p>You can't revert pages to a previous revision because " . ($settings->history_revert_require_moderator && $env->is_logged_in ? "you aren't logged in as a moderator. You can try <a href='?action=logout'>logging out</a> and then" : "you aren't logged in. You can try") . " <a href='?action=login&returnto=" . rawurlencode("?action=history-revert&revision={$env->history->revision_number}&page=" . rawurlencode($env->page)) . "'>logging in</a>.</p>"));
 			}
 			
 			$current_revision_filepath = "$env->storage_prefix/{$pageindex->{$env->page}->filename}";
diff --git a/module_index.json b/module_index.json
index ef76375..9760873 100755
--- a/module_index.json
+++ b/module_index.json
@@ -77,7 +77,7 @@
         "author": "Starbeamrainbowlabs",
         "description": "Adds the ability to keep unlimited page history, limited only by your disk space. Note that this doesn't store file history (yet). Currently depends on feature-recent-changes for rendering of the history page.",
         "id": "feature-history",
-        "lastupdate": 1530615218,
+        "lastupdate": 1530615427,
         "optional": false
     },
     {
diff --git a/modules/feature-history.php b/modules/feature-history.php
index f1cad59..d65f8c2 100644
--- a/modules/feature-history.php
+++ b/modules/feature-history.php
@@ -116,9 +116,9 @@ register_module([
 			global $env, $settings, $pageindex;
 			
 			if((!$env->is_admin && $settings->history_revert_require_moderator) ||
-				$env->is_logged_in) {
+				!$env->is_logged_in) {
 				http_response_code(401);
-				exit(page_renderer::render_main("Unauthorised - $settings->sitename", "<p>You can't revert pages to a previous revision because " . ($settings->history_revert_require_moderator && $env->is_logged_in ? "you aren't logged in as a moderator. You can try <a href='?action=logout'>logging out</a> and then" : "you aren't logged in. You can try") . " <a href='?action=login&returnto=" . rawurlencode("?action=history-revert&revision={$env->history->revision_number}&page=" . rawurlencode($env->page)) . "logging in</a>."));
+				exit(page_renderer::render_main("Unauthorised - $settings->sitename", "<p>You can't revert pages to a previous revision because " . ($settings->history_revert_require_moderator && $env->is_logged_in ? "you aren't logged in as a moderator. You can try <a href='?action=logout'>logging out</a> and then" : "you aren't logged in. You can try") . " <a href='?action=login&returnto=" . rawurlencode("?action=history-revert&revision={$env->history->revision_number}&page=" . rawurlencode($env->page)) . "'>logging in</a>.</p>"));
 			}
 			
 			$current_revision_filepath = "$env->storage_prefix/{$pageindex->{$env->page}->filename}";
