Implement more advanced 2FA library

This commit is contained in:
2022-11-28 19:45:22 +00:00
parent 7a64759ceb
commit 0fc7c5c712
31 changed files with 406 additions and 41 deletions

View File

@@ -5,6 +5,7 @@ from django.http import HttpResponseBadRequest
from django.shortcuts import render
from django.views import View
from rest_framework.parsers import FormParser
from two_factor.views.mixins import OTPRequiredMixin
from core.exchanges import GenericAPIError
from core.models import Account
@@ -27,14 +28,14 @@ def get_positions(user, account_id=None):
return items
class Positions(LoginRequiredMixin, View):
class Positions(LoginRequiredMixin, OTPRequiredMixin, View):
allowed_types = ["modal", "widget", "window", "page"]
window_content = "window-content/objects.html"
list_template = "partials/position-list.html"
page_title = "Live positions from all exchanges"
page_subtitle = "Manual trades are editable under 'Bot Trades' tab."
async def get(self, request, type, account_id=None):
def get(self, request, type, account_id=None):
if type not in self.allowed_types:
return HttpResponseBadRequest
template_name = f"wm/{type}.html"
@@ -55,12 +56,12 @@ class Positions(LoginRequiredMixin, View):
return render(request, template_name, context)
class PositionAction(LoginRequiredMixin, View):
class PositionAction(LoginRequiredMixin, OTPRequiredMixin, View):
allowed_types = ["modal", "widget", "window", "page"]
window_content = "window-content/view-position.html"
parser_classes = [FormParser]
async def get(self, request, type, account_id, symbol):
def get(self, request, type, account_id, symbol):
"""
Get live information for a trade.
"""