Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: display private pages for logged in users #274

Merged
merged 1 commit into from
Sep 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions wiki/wiki/doctype/wiki_page/wiki_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,9 @@ def update_page(self, title, content, edit_message, raised_by=None):

self.save()

def verify_permission(self, permtype):
if permtype == "read" and self.allow_guest:
return True
permitted = frappe.has_permission(self.doctype, permtype, self)
def verify_permission(self):
permitted = self.allow_guest or frappe.session.user != "Guest"
if not permitted:
action = permtype
if action == "write":
action = "edit"
frappe.local.response["type"] = "redirect"
frappe.local.response["location"] = "/login?" + urlencode({"redirect-to": frappe.request.url})
raise frappe.Redirect
Expand Down Expand Up @@ -205,7 +200,7 @@ def calculate_toc_html(self, html):
return toc_html

def get_context(self, context):
self.verify_permission("read")
self.verify_permission()
self.set_breadcrumbs(context)

wiki_settings = frappe.get_single("Wiki Settings")
Expand Down Expand Up @@ -310,10 +305,9 @@ def get_sidebar_items(self):

wiki_page = frappe.get_doc("Wiki Page", sidebar_item.wiki_page)

if not wiki_page.allow_guest:
permitted = frappe.has_permission(wiki_page.doctype, "read", wiki_page)
if not permitted:
continue
permitted = wiki_page.allow_guest or frappe.session.user != "Guest"
if not permitted:
continue

if sidebar_item.parent_label not in sidebar:
sidebar[sidebar_item.parent_label] = [
Expand Down
Loading