Commit a1c10368 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[ui][registration] Add app configuration for two_factor customization

In order for the two_factor module to still send an email
upon successful login on a blocked account, monkey patch the
list of forms used and replace the one for the auth step with
the custom version that sends an email.
parent 889142c6
......@@ -28,6 +28,33 @@ from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _
def monkey_patch_2fa_authentication_form():
This methods monkey patches the list of forms used by the 2fa LoginView.
It replaces the standard form with a custom one that sends an email on successful
login with an account that is blocked.
from two_factor.views import LoginView
from .forms import AuthenticationFormSendingWarning
form_list = []
for form_tuple in LoginView.form_list:
if form_tuple[0] == "auth":
form_list.append(("auth", AuthenticationFormSendingWarning))
LoginView.form_list = form_list
class UiRegistrationConfig(AppConfig):
name = "beat.web.ui.registration"
verbose_name = _("Ui Registration")
def ready(self):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment