mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 03:21:05 +00:00
Disallow registration in install mode and adds redirects
This commit is contained in:
parent
8e3c39d319
commit
b4e0749f73
4 changed files with 19 additions and 4 deletions
|
@ -59,7 +59,7 @@ urlpatterns = [
|
|||
name="stream-updates",
|
||||
),
|
||||
# instance setup
|
||||
re_path(r"^setup/?$", views.CreateAdmin.as_view(), name="setup-admin"),
|
||||
re_path(r"^setup/?$", views.CreateAdmin.as_view(), name="setup"),
|
||||
# authentication
|
||||
re_path(r"^login/?$", views.Login.as_view(), name="login"),
|
||||
re_path(r"^login/(?P<confirmed>confirmed)/?$", views.Login.as_view(), name="login"),
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
""" non-interactive pages """
|
||||
from django.shortcuts import redirect
|
||||
from django.template.response import TemplateResponse
|
||||
from django.views import View
|
||||
|
||||
from bookwyrm import forms
|
||||
from bookwyrm import forms, models
|
||||
from bookwyrm.views.feed import Feed
|
||||
|
||||
|
||||
|
@ -15,6 +16,11 @@ class Home(View):
|
|||
if request.user.is_authenticated:
|
||||
feed_view = Feed.as_view()
|
||||
return feed_view(request, "home")
|
||||
site = models.SiteSettings.objects.get()
|
||||
|
||||
if site.install_mode:
|
||||
return redirect("setup")
|
||||
|
||||
landing_view = Landing.as_view()
|
||||
return landing_view(request)
|
||||
|
||||
|
|
|
@ -25,6 +25,10 @@ class Register(View):
|
|||
def post(self, request):
|
||||
"""join the server"""
|
||||
settings = models.SiteSettings.get()
|
||||
# no registration allowed when the site is being installed
|
||||
if settings.install_mode:
|
||||
raise PermissionDenied()
|
||||
|
||||
if not settings.allow_registration:
|
||||
invite_code = request.POST.get("invite_code")
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
""" Installation wizard 🧙 """
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.template.response import TemplateResponse
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.views import View
|
||||
|
||||
from bookwyrm import emailing, forms, models
|
||||
from bookwyrm import forms, models
|
||||
|
||||
|
||||
# pylint: disable= no-self-use
|
||||
|
@ -12,6 +12,11 @@ class CreateAdmin(View):
|
|||
|
||||
def get(self, request):
|
||||
"""Create admin user"""
|
||||
# only allow this view when an instance is being installed
|
||||
site = models.SiteSettings.objects.get()
|
||||
if not site.install_mode:
|
||||
raise PermissionDenied()
|
||||
|
||||
data = {
|
||||
"register_form": forms.RegisterForm()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue