Code Monkey home page Code Monkey logo

Comments (7)

Danane84 avatar Danane84 commented on July 20, 2024 1

Indeed, syncing the clocks of my TOTP device and my computer solved the problem. Many thanks for your guidance!

from django-allauth-2fa.

clokep avatar clokep commented on July 20, 2024

My guess would be that the included form isn't working for some reason. Do you do something weird with CSRF tokens? Are you overriding the template?

from django-allauth-2fa.

Danane84 avatar Danane84 commented on July 20, 2024

The only two places where I am using CSRF tokens are in my login.html and logout.html files.

login.html:

{% extends '_base.html' %}
{% load static %}
{% load crispy_forms_tags %}

{% block title %}Login{% endblock title %}

{% block content %}
<div class="card">

    <form method="post">
        {% csrf_token %}
        {{ form|crispy }}
        <div class="form-group mb-0 text-center">
        <button class="btn btn-primary" type="submit">Log In</button>
        </div>
    </form>

</div>
{% endblock content %}

logout.html:

{% extends '_base.html' %}
{% load static %}
{% load crispy_forms_tags %}


{% block content %}
<div class="card-body p-4">
                                
    <div class="text-center w-75 m-auto">
        <h4 class="text-dark-50 text-center mt-3 font-weight-bold">Hi {{ user.email }}!</h4>
        <p class="text-muted mb-4">Are you sure you want to sign out?</p>
    </div>

    <div class="container">
        <form method="post" action="{% url 'account_logout' %}">
            {% csrf_token %}
            {{ form|crispy }}
            <div class="form-group mb-0 text-center">
                <button class="btn btn-danger" type="submit">Log Out</button>
            </div>
        </form>
    </div>
    
</div>
  
{% endblock content %}

from django-allauth-2fa.

clokep avatar clokep commented on July 20, 2024

I meant the templates that allauth-2fa uses.

Although now that I'm looking at the view again, this most likely occurs if you enter the wrong information. Do the clocks on the computer that is running your Django app and your TOTP devices match?

from django-allauth-2fa.

Danane84 avatar Danane84 commented on July 20, 2024

My computer is 1min 25 sec behind my TOTP device (iPhone). But could this be the issue? It might always be the case that the TOTP device of at least one of the users of the app is slighty off compared to the time of the server.

I also tried to set the TIME_ZONE in my settings.py from 'UTC' to 'Europe/Vienna' but it did not solve the issue

from django-allauth-2fa.

clokep avatar clokep commented on July 20, 2024

My computer is 1min 25 sec behind my TOTP device (iPhone). But could this be the issue?

Yes, TOTP codes are valid for 30 seconds only.

It seems like django-otp has some configuration options for this though: https://github.com/django-otp/django-otp/blob/master/docs/source/overview.rst#totp-devices

from django-allauth-2fa.

clokep avatar clokep commented on July 20, 2024

Seems like we should be showing an error on the form if the TOTP code is wrong though. 😒

from django-allauth-2fa.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.