Allow configuring landing page for unauthenticated users (#808)

* allow configuring landing page

* add tests
This commit is contained in:
Sascha Ißbrücker
2024-08-31 15:39:22 +02:00
committed by GitHub
parent 36749c398b
commit 5eadb3ede3
12 changed files with 261 additions and 46 deletions

18
bookmarks/views/root.py Normal file
View File

@@ -0,0 +1,18 @@
from django.http import HttpResponseRedirect
from django.urls import reverse
from bookmarks.models import GlobalSettings
def root(request):
# Redirect unauthenticated users to the configured landing page
if not request.user.is_authenticated:
settings = GlobalSettings.get()
if settings.landing_page == GlobalSettings.LANDING_PAGE_SHARED_BOOKMARKS:
return HttpResponseRedirect(reverse("bookmarks:shared"))
else:
return HttpResponseRedirect(reverse("login"))
# Redirect authenticated users to the bookmarks page
return HttpResponseRedirect(reverse("bookmarks:index"))