mirror of
https://github.com/pretix/pretix.git
synced 2026-09-13 16:14:40 +00:00
Allow to disable login/password reset
This commit is contained in:
@@ -51,6 +51,12 @@ Example::
|
|||||||
``cookie_domain``
|
``cookie_domain``
|
||||||
The cookie domain to be set. Defaults to ``None``.
|
The cookie domain to be set. Defaults to ``None``.
|
||||||
|
|
||||||
|
``registration``
|
||||||
|
Enables or disables the registration of new admin users. Defaults to ``on``.
|
||||||
|
|
||||||
|
``password_reset``
|
||||||
|
Enables or disables password reset. Defaults to ``on``.
|
||||||
|
|
||||||
|
|
||||||
Locale settings
|
Locale settings
|
||||||
---------------
|
---------------
|
||||||
|
|||||||
@@ -9,19 +9,23 @@
|
|||||||
{% bootstrap_field form.email %}
|
{% bootstrap_field form.email %}
|
||||||
{% bootstrap_field form.password %}
|
{% bootstrap_field form.password %}
|
||||||
<div class="form-group buttons">
|
<div class="form-group buttons">
|
||||||
<a href="{% url "control:auth.forgot" %}" class="btn btn-link">
|
{% if can_reset %}
|
||||||
{% trans "Lost password?" %}
|
<a href="{% url "control:auth.forgot" %}" class="btn btn-link">
|
||||||
</a>
|
{% trans "Lost password?" %}
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<button type="submit" class="btn btn-primary">
|
<button type="submit" class="btn btn-primary">
|
||||||
{% trans "Log in" %}
|
{% trans "Log in" %}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group buttons">
|
{% if can_register %}
|
||||||
<a href="{% url "control:auth.register" %}" class="btn btn-link">
|
<div class="form-group buttons">
|
||||||
{% trans "Register" %}
|
<a href="{% url "control:auth.register" %}" class="btn btn-link">
|
||||||
</a>
|
{% trans "Register" %}
|
||||||
</div>
|
</a>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
</form>
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from django.contrib.auth import (
|
|||||||
authenticate, login as auth_login, logout as auth_logout,
|
authenticate, login as auth_login, logout as auth_logout,
|
||||||
)
|
)
|
||||||
from django.contrib.auth.tokens import default_token_generator
|
from django.contrib.auth.tokens import default_token_generator
|
||||||
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.shortcuts import redirect, render
|
from django.shortcuts import redirect, render
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
@@ -35,6 +36,8 @@ def login(request):
|
|||||||
else:
|
else:
|
||||||
form = LoginForm()
|
form = LoginForm()
|
||||||
ctx['form'] = form
|
ctx['form'] = form
|
||||||
|
ctx['can_register'] = settings.PRETIX_REGISTRATION
|
||||||
|
ctx['can_reset'] = settings.PRETIX_PASSWORD_RESET
|
||||||
return render(request, 'pretixcontrol/auth/login.html', ctx)
|
return render(request, 'pretixcontrol/auth/login.html', ctx)
|
||||||
|
|
||||||
|
|
||||||
@@ -50,6 +53,8 @@ def register(request):
|
|||||||
"""
|
"""
|
||||||
Render and process a basic registration form.
|
Render and process a basic registration form.
|
||||||
"""
|
"""
|
||||||
|
if not settings.PRETIX_REGISTRATION:
|
||||||
|
raise PermissionDenied('Registration is disabled')
|
||||||
ctx = {}
|
ctx = {}
|
||||||
if request.user.is_authenticated():
|
if request.user.is_authenticated():
|
||||||
return redirect(request.GET.get("next", 'control:index'))
|
return redirect(request.GET.get("next", 'control:index'))
|
||||||
@@ -74,6 +79,11 @@ def register(request):
|
|||||||
class Forgot(TemplateView):
|
class Forgot(TemplateView):
|
||||||
template_name = 'pretixcontrol/auth/forgot.html'
|
template_name = 'pretixcontrol/auth/forgot.html'
|
||||||
|
|
||||||
|
def dispatch(self, request, *args, **kwargs):
|
||||||
|
if not settings.PRETIX_PASSWORD_RESET:
|
||||||
|
raise PermissionDenied('Password reset is disabled')
|
||||||
|
return super().dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
if request.user.is_authenticated():
|
if request.user.is_authenticated():
|
||||||
return redirect(request.GET.get("next", 'control:index'))
|
return redirect(request.GET.get("next", 'control:index'))
|
||||||
@@ -128,6 +138,11 @@ class Recover(TemplateView):
|
|||||||
'unknownuser': _('We were unable to find the user you requested a new password for.')
|
'unknownuser': _('We were unable to find the user you requested a new password for.')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def dispatch(self, request, *args, **kwargs):
|
||||||
|
if not settings.PRETIX_PASSWORD_RESET:
|
||||||
|
raise PermissionDenied('Password reset is disabled')
|
||||||
|
return super().dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
if request.user.is_authenticated():
|
if request.user.is_authenticated():
|
||||||
return redirect(request.GET.get("next", 'control:index'))
|
return redirect(request.GET.get("next", 'control:index'))
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ STATIC_URL = config.get('urls', 'static', fallback='/static/')
|
|||||||
MEDIA_URL = config.get('urls', 'media', fallback='/media/')
|
MEDIA_URL = config.get('urls', 'media', fallback='/media/')
|
||||||
|
|
||||||
PRETIX_INSTANCE_NAME = config.get('pretix', 'instance_name', fallback='pretix.de')
|
PRETIX_INSTANCE_NAME = config.get('pretix', 'instance_name', fallback='pretix.de')
|
||||||
|
PRETIX_REGISTRATION = config.getboolean('pretix', 'registration', fallback=True)
|
||||||
|
PRETIX_PASSWORD_RESET = config.getboolean('pretix', 'password_reset', fallback=True)
|
||||||
|
|
||||||
SITE_URL = config.get('pretix', 'url', fallback='http://localhost')
|
SITE_URL = config.get('pretix', 'url', fallback='http://localhost')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user