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

Initial support for password restricted pages #3839

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 7 additions & 0 deletions backend/api/cms/page/queries/cms_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,20 @@
hostname: str,
slug: str,
language: str,
password: str | None = None,
) -> GenericPage | SiteNotFoundError | None:
site = get_site_by_host(hostname)

if not site:
return SiteNotFoundError(message=f"Site `{hostname}` not found")

page = GenericPageModel.objects.in_site(site).filter(slug=slug).first()
password_restriction = (
page.get_view_restrictions().filter(restriction_type="password").first()
)

if password_restriction and password_restriction.value != password:
return None

Check warning on line 27 in backend/api/cms/page/queries/cms_page.py

View check run for this annotation

Codecov / codecov/patch

backend/api/cms/page/queries/cms_page.py#L27

Added line #L27 was not covered by tests

if not page:
return None
Expand Down
Loading