remove obsolete view

This commit is contained in:
wh1te909 2020-06-01 08:23:14 +00:00
parent 45906427ae
commit 06b92ac74b
2 changed files with 3 additions and 26 deletions

View File

@ -5,17 +5,11 @@ from django.conf import settings
from rest_framework.authtoken.serializers import AuthTokenSerializer
from knox.views import LoginView as KnoxLoginView
from rest_framework.authentication import BasicAuthentication
from rest_framework.permissions import IsAuthenticated, AllowAny
from rest_framework.permissions import AllowAny
from rest_framework.response import Response
from rest_framework import status
from rest_framework.decorators import (
api_view,
authentication_classes,
permission_classes,
)
from accounts.models import User
from .models import User
class CheckCreds(KnoxLoginView):
@ -52,19 +46,3 @@ class LoginView(KnoxLoginView):
return super(LoginView, self).post(request, format=None)
else:
return Response("bad credentials", status=status.HTTP_400_BAD_REQUEST)
@api_view(["POST"])
@authentication_classes((BasicAuthentication,))
@permission_classes((IsAuthenticated,))
def installer_twofactor(request):
token = request.data["twofactorToken"]
totp = pyotp.TOTP(request.user.totp_key)
if settings.DEBUG and token == "sekret":
return Response("ok")
elif totp.verify(token, valid_window=1):
return Response("ok")
else:
return Response("bad 2 factor code", status=status.HTTP_400_BAD_REQUEST)

View File

@ -2,7 +2,7 @@ from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from knox import views as knox_views
from accounts.views import LoginView, CheckCreds, installer_twofactor
from accounts.views import LoginView, CheckCreds
urlpatterns = [
path(settings.ADMIN_URL, admin.site.urls),
@ -10,7 +10,6 @@ urlpatterns = [
path("login/", LoginView.as_view()),
path("logout/", knox_views.LogoutView.as_view()),
path("logoutall/", knox_views.LogoutAllView.as_view()),
path("installer/twofactor/", installer_twofactor),
path("api/v1/", include("api.urls")),
path("clients/", include("clients.urls")),
path("agents/", include("agents.urls")),