# HG changeset patch # User Peter Sanchez # Date 1630978864 25200 # Mon Sep 06 18:41:04 2021 -0700 # Node ID d845b3df41b03f8e369e2d8a5c7471a243b701d9 # Parent bd572a6ac9e76ab7c49a34698f41c343b0811e7f Fixing edge case bug in setup. diff --git a/nlotp/__init__.py b/nlotp/__init__.py --- a/nlotp/__init__.py +++ b/nlotp/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- default_app_config = "nlotp.apps.NLOTPConfig" -VERSION = (0, 1, 1, "final", 0) +VERSION = (0, 1, 2, "final", 0) def get_version(): diff --git a/nlotp/views.py b/nlotp/views.py --- a/nlotp/views.py +++ b/nlotp/views.py @@ -3,8 +3,6 @@ from django.contrib import messages from django.contrib.auth.mixins import LoginRequiredMixin from django.http import HttpResponse -from django.shortcuts import get_object_or_404 -from django.urls import reverse_lazy from django.views.generic.edit import FormView, View from django_otp import DEVICE_ID_SESSION_KEY from django_otp import login as otp_login @@ -42,6 +40,9 @@ def setup(self, request, *args, **kwargs): super().setup(request, *args, **kwargs) + if not request.user.is_authenticated: + return + self.totp_device = utils.get_user_totp_device(self.request.user) self.static_device = utils.get_user_static_device(self.request.user) self.generate_codes = "auth-generate_codes" in self.request.POST