Optional two factor and device registration view

77 views
Skip to the first unread message

j.rom...@gmail.com

unread,
15 Mar 2018, 18:20:2215/03/2018
to django-otp
Hello, I have a simple question, I want that my user be able to login without 2fa once, but when he's logged in be redirected to a register totp device view, I need to know if the user that is logged in has a device related, if not make redirection to the view to vinculate a totp device.

Karl Goetz

unread,
15 Mar 2018, 18:33:2015/03/2018
to j.rom...@gmail.com, django-otp
There is a user_has_device function you can import from django_otp to test if any devices are registered to the user.

I can't remember if the supplied forms can do what you need but I suggest you check the doc's in case they do.
Kk



On 16 March 2018 9:20:22 am AEDT, j.rom...@gmail.com wrote:
Hello, I have a simple question, I want that my user be able to login without 2fa once, but when he's logged in be redirected to a register totp device view, I need to know if the user that is logged in has a device related, if not make redirection to the view to vinculate a totp device.


--
Sent from my Android device with K-9 Mail. Please excuse my brevity.

j.rom...@gmail.com

unread,
15 Mar 2018, 18:38:5615/03/2018
to django-otp
I have something like:

if device.objects.filter(user=request.user).count() < 1 and request.path != reverse('app:view'):
    return redirect('app:view')

but I want to optimize this using only request parameters not db queries.

Some advice to do this?
Reply all
Reply to author
Forward
0 new messages