Draft: Two factor auth #118
3 changed files with 18 additions and 5 deletions
|
|
@ -10,7 +10,6 @@ from two_factor.views import (
|
||||||
ProfileView,
|
ProfileView,
|
||||||
QRGeneratorView,
|
QRGeneratorView,
|
||||||
SetupCompleteView,
|
SetupCompleteView,
|
||||||
SetupView,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
from newsreader.accounts.views import (
|
from newsreader.accounts.views import (
|
||||||
|
|
@ -33,6 +32,7 @@ from newsreader.accounts.views import (
|
||||||
RegistrationCompleteView,
|
RegistrationCompleteView,
|
||||||
RegistrationView,
|
RegistrationView,
|
||||||
SettingsView,
|
SettingsView,
|
||||||
|
SetupView,
|
||||||
TwitterAuthRedirectView,
|
TwitterAuthRedirectView,
|
||||||
TwitterRevokeRedirectView,
|
TwitterRevokeRedirectView,
|
||||||
TwitterTemplateView,
|
TwitterTemplateView,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
from newsreader.accounts.views.auth import LoginView, LogoutView
|
from newsreader.accounts.views.auth import LoginView, LogoutView, SetupView
|
||||||
from newsreader.accounts.views.favicon import FaviconRedirectView
|
from newsreader.accounts.views.favicon import FaviconRedirectView
|
||||||
from newsreader.accounts.views.integrations import (
|
from newsreader.accounts.views.integrations import (
|
||||||
IntegrationsView,
|
IntegrationsView,
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,30 @@
|
||||||
from django.contrib.auth import views as django_views
|
from django.contrib.auth import views as django_views
|
||||||
|
from django.shortcuts import redirect
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
|
|
||||||
from two_factor.views.core import LoginView as TwoFactorLoginView
|
from two_factor.views.core import LoginView as TwoFactorLoginView
|
||||||
|
from two_factor.views.core import SetupView as TwoFactorSetupView
|
||||||
|
|
||||||
|
|
||||||
class LoginView(TwoFactorLoginView):
|
class LoginView(TwoFactorLoginView):
|
||||||
redirect_authenticated_user = True
|
redirect_authenticated_user = True
|
||||||
template_name = "accounts/views/login.html"
|
template_name = "accounts/views/login.html"
|
||||||
|
|
||||||
def post(self, *args, **kwargs):
|
def done(self, form_list, **kwargs):
|
||||||
print(self.request.POST)
|
response = super().done(form_list, **kwargs)
|
||||||
return super().post(*args, **kwargs)
|
|
||||||
|
user = self.get_user()
|
||||||
|
|
||||||
|
if not user.phonedevice_set.exists():
|
||||||
|
return redirect("accounts:two_factor:setup")
|
||||||
|
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
class LogoutView(django_views.LogoutView):
|
class LogoutView(django_views.LogoutView):
|
||||||
next_page = reverse_lazy("accounts:login")
|
next_page = reverse_lazy("accounts:login")
|
||||||
|
|
||||||
|
|
||||||
|
class SetupView(TwoFactorSetupView):
|
||||||
|
success_url = "accounts:two_factor:setup_complete"
|
||||||
|
qrcode_url = "accounts:two_factor:qr"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue