otp_time: fix linting
This commit is contained in:
parent
812aa4ced5
commit
a4c0fb9e75
|
@ -0,0 +1,8 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class PassbookStageOTPStaticConfig(AppConfig):
|
||||
|
||||
name = "passbook.stages.otp_static"
|
||||
label = "passbook_stages_otp_static"
|
||||
verbose_name = "passbook OTP.Static"
|
|
@ -1,7 +1,9 @@
|
|||
"""OTP Time"""
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class PassbookStageOTPTimeConfig(AppConfig):
|
||||
"""OTP time App config"""
|
||||
|
||||
name = "passbook.stages.otp_time"
|
||||
label = "passbook_stages_otp_time"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
"""OTP Time forms"""
|
||||
from django import forms
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
@ -15,6 +16,7 @@ class PictureWidget(forms.widgets.Widget):
|
|||
|
||||
|
||||
class SetupForm(forms.Form):
|
||||
"""Form to setup Time-based OTP"""
|
||||
|
||||
title = _("Set up OTP")
|
||||
device: Device = None
|
||||
|
@ -40,6 +42,8 @@ class SetupForm(forms.Form):
|
|||
|
||||
|
||||
class OTPTimeStageForm(forms.ModelForm):
|
||||
"""OTP Time-based Stage setup form"""
|
||||
|
||||
class Meta:
|
||||
|
||||
model = OTPTimeStage
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
"""OTP Time-based models"""
|
||||
from typing import Optional
|
||||
|
||||
from django.db import models
|
||||
from django.shortcuts import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from passbook.core.types import UIUserSettings
|
||||
from passbook.flows.models import NotConfiguredAction, Stage
|
||||
from django.template.context import RequestContext
|
||||
from passbook.flows.models import Stage
|
||||
|
||||
|
||||
class TOTPDigits(models.IntegerChoices):
|
||||
"""OTP Time Digits"""
|
||||
|
||||
SIX = 6, _("6 digits, widely compatible")
|
||||
EIGHT = 8, _("8 digits, not compatible with apps like Google Authenticator")
|
||||
|
@ -21,12 +24,11 @@ class OTPTimeStage(Stage):
|
|||
type = "passbook.stages.otp_time.stage.OTPTimeStageView"
|
||||
form = "passbook.stages.otp_time.forms.OTPTimeStageForm"
|
||||
|
||||
@staticmethod
|
||||
def ui_user_settings(context: RequestContext) -> Optional[UIUserSettings]:
|
||||
@property
|
||||
def ui_user_settings(self) -> Optional[UIUserSettings]:
|
||||
return UIUserSettings(
|
||||
name="Time-based OTP",
|
||||
icon="pficon-locked",
|
||||
view_name="passbook_stages_otp_time:user-settings",
|
||||
url=reverse("passbook_stages_otp_time:user-settings"),
|
||||
)
|
||||
|
||||
def __str__(self) -> str:
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
"""OTP Time"""
|
||||
|
||||
INSTALLED_APPS = [
|
||||
"django_otp.plugins.otp_totp",
|
||||
]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from typing import Any, Dict
|
||||
from base64 import b32encode
|
||||
from binascii import unhexlify
|
||||
from typing import Any, Dict
|
||||
|
||||
from django.contrib import messages
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
"""OTP Time urls"""
|
||||
from django.urls import path
|
||||
|
||||
from passbook.stages.otp_time.views import UserSettingsView, DisableView
|
||||
from passbook.stages.otp_time.views import DisableView, UserSettingsView
|
||||
|
||||
urlpatterns = [
|
||||
path("settings", UserSettingsView.as_view(), name="user-settings"),
|
||||
path("disable", DisableView.as_view(), name="disable")
|
||||
path("disable", DisableView.as_view(), name="disable"),
|
||||
]
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
"""otp time-based view"""
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.views import View
|
||||
from django.views.generic import FormView, TemplateView
|
||||
from django_otp.plugins.otp_totp.models import TOTPDevice
|
||||
from django.contrib import messages
|
||||
from passbook.audit.models import Event, EventAction
|
||||
from django.shortcuts import redirect
|
||||
from django.views import View
|
||||
from django.views.generic import TemplateView
|
||||
from django_otp.plugins.otp_totp.models import TOTPDevice
|
||||
|
||||
from passbook.flows.planner import PLAN_CONTEXT_PENDING_USER, FlowPlan
|
||||
from passbook.flows.views import SESSION_KEY_PLAN
|
||||
from passbook.stages.otp_time.models import OTPTimeStage
|
||||
from passbook.audit.models import Event, EventAction
|
||||
|
||||
# from passbook.flows.planner import PLAN_CONTEXT_PENDING_USER, FlowPlan
|
||||
# from passbook.flows.views import SESSION_KEY_PLAN
|
||||
# from passbook.stages.otp_time.models import OTPTimeStage
|
||||
|
||||
|
||||
class UserSettingsView(LoginRequiredMixin, TemplateView):
|
||||
|
@ -34,5 +36,7 @@ class DisableView(LoginRequiredMixin, View):
|
|||
totp.delete()
|
||||
messages.success(request, "Successfully disabled Time-based OTP")
|
||||
# Create event with email notification
|
||||
Event.new(EventAction.CUSTOM, message="User disabled Time-based OTP.").from_http(request)
|
||||
Event.new(
|
||||
EventAction.CUSTOM, message="User disabled Time-based OTP."
|
||||
).from_http(request)
|
||||
return redirect("passbook_stages_otp:otp-user-settings")
|
||||
|
|
Reference in New Issue