Skip to content

Commit 6d3c916

Browse files
committed
django 5.1: support LoginRequiredMiddleware
1 parent 48dd370 commit 6d3c916

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

mfa/views.py

+7
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@
2727
def stronghold_public(view_func):
2828
return view_func
2929

30+
try:
31+
from django.contrib.auth.decorators import login_not_required
32+
except ImportError:
33+
def login_not_required(view_func):
34+
return view_func
35+
3036

3137
class LoginView(DjangoLoginView):
3238
def no_key_exists(self, form):
@@ -90,6 +96,7 @@ def form_valid(self, form):
9096
return super().form_valid(form)
9197

9298

99+
@method_decorator(login_not_required, name='dispatch')
93100
@method_decorator(stronghold_public, name='dispatch')
94101
class MFAAuthView(MFAFormView):
95102
form_class = MFAAuthForm

0 commit comments

Comments
 (0)