jazzband / django-two-factor-auth

Complete Two-Factor Authentication for Django providing the easiest integration into most Django projects.
MIT License
1.71k stars 448 forks source link

Is it possible to verify superuser authentication with the first login form (before the 2fa token step)? #536

Open statsconchris opened 2 years ago

statsconchris commented 2 years ago

In the first form you type the username and password. If this is correct then you move to the second step, which is typing the 2fa token.

I want to verify with the first form if the user is superuser or not. If it is then I want to type a message in the second step (2fa token form) In my two_factor/core/login.html template I write:

{% if backup_tokens %}
  {% if user.is_superuser %}
    <p>superuser</p>
  {% endif %}
  ...
  ...
{%  endif %}

But it doesn't work. I also tried with user.is_authenticated and request.user.is_superuser. I'm surprised that not even the former works. Is this a bug? I just want to reach the second step with a special message if it is a superuser

Python version: +3.9.2 Django version : +4.0.3 django-otp version: +1.1.3 django-two-factor-auth version : +1.13.2