This is my custom login view where user can only login if their email verified. I also added two step verification in my login view. is there any way where I can implement this view in django admin login ?
def login_view(request):
username = None
password = None
two_factor = None
if request.method == 'POST':
username = request.POST.get('username')
password = request.POST.get('password')
otp = request.POST.get('auth_code')
user = authenticate(request, username=username, password=password)
User = get_user_model()
if user is not None and user.is_active:
user_mail = user.userprofile.filter(
user=user, email_confirmed=True)
two_factor = user.userprofile.filter(
user=user, two_factor=True)
for i in two_factor:
....my two factor code
if user_mail and two_factor:
if secret_code == otp:
login(request, user)