Skip to content

Commit

Permalink
Merge pull request #53 from stuartmaxwell/dev
Browse files Browse the repository at this point in the history
Check if user is authenticated.
  • Loading branch information
stuartmaxwell authored May 23, 2024
2 parents 3ad0afd + b163945 commit 6802ba3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion djpress_admin/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import logging

from django.http import HttpRequest, HttpResponse
from django.shortcuts import render
from django.shortcuts import redirect, render
from django.urls import reverse

from djpress.utils import render_markdown

Expand All @@ -14,6 +15,9 @@ def index(
request: HttpRequest,
) -> HttpResponse:
"""View for the index page."""
if not request.user.is_authenticated:
return redirect(f"{reverse('djpress:index')}")

return render(
request,
"djpress_admin/index.html",
Expand All @@ -22,6 +26,9 @@ def index(

def preview_markdown(request: HttpRequest) -> HttpResponse:
"""View for the preview markdown page."""
if not request.user.is_authenticated:
return redirect(f"{reverse('djpress:index')}")

html = ""
error = ""

Expand Down

0 comments on commit 6802ba3

Please sign in to comment.