Draft: Two factor auth #118
3 changed files with 18 additions and 5 deletions
|
|
@ -10,7 +10,6 @@ from two_factor.views import (
|
|||
ProfileView,
|
||||
QRGeneratorView,
|
||||
SetupCompleteView,
|
||||
SetupView,
|
||||
)
|
||||
|
||||
from newsreader.accounts.views import (
|
||||
|
|
@ -33,6 +32,7 @@ from newsreader.accounts.views import (
|
|||
RegistrationCompleteView,
|
||||
RegistrationView,
|
||||
SettingsView,
|
||||
SetupView,
|
||||
TwitterAuthRedirectView,
|
||||
TwitterRevokeRedirectView,
|
||||
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.integrations import (
|
||||
IntegrationsView,
|
||||
|
|
|
|||
|
|
@ -1,17 +1,30 @@
|
|||
from django.contrib.auth import views as django_views
|
||||
from django.shortcuts import redirect
|
||||
from django.urls import reverse_lazy
|
||||
|
||||
from two_factor.views.core import LoginView as TwoFactorLoginView
|
||||
from two_factor.views.core import SetupView as TwoFactorSetupView
|
||||
|
||||
|
||||
class LoginView(TwoFactorLoginView):
|
||||
redirect_authenticated_user = True
|
||||
template_name = "accounts/views/login.html"
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
print(self.request.POST)
|
||||
return super().post(*args, **kwargs)
|
||||
def done(self, form_list, **kwargs):
|
||||
response = super().done(form_list, **kwargs)
|
||||
|
||||
user = self.get_user()
|
||||
|
||||
if not user.phonedevice_set.exists():
|
||||
return redirect("accounts:two_factor:setup")
|
||||
|
||||
return response
|
||||
|
||||
|
||||
class LogoutView(django_views.LogoutView):
|
||||
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