stages/otp_*: Remove duplicate validation for OTP Codes
This commit is contained in:
parent
fe3634be64
commit
247015e955
|
@ -5,7 +5,6 @@ from django.utils.translation import gettext_lazy as _
|
||||||
from django_otp.models import Device
|
from django_otp.models import Device
|
||||||
|
|
||||||
from passbook.stages.otp_time.models import OTPTimeStage
|
from passbook.stages.otp_time.models import OTPTimeStage
|
||||||
from passbook.stages.otp_validate.forms import OTP_CODE_VALIDATOR
|
|
||||||
|
|
||||||
|
|
||||||
class PictureWidget(forms.widgets.Widget):
|
class PictureWidget(forms.widgets.Widget):
|
||||||
|
@ -28,7 +27,6 @@ class SetupForm(forms.Form):
|
||||||
)
|
)
|
||||||
code = forms.CharField(
|
code = forms.CharField(
|
||||||
label=_("Please enter the Token on your device."),
|
label=_("Please enter the Token on your device."),
|
||||||
validators=[OTP_CODE_VALIDATOR],
|
|
||||||
widget=forms.TextInput(
|
widget=forms.TextInput(
|
||||||
attrs={
|
attrs={
|
||||||
"autocomplete": "off",
|
"autocomplete": "off",
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
"""OTP Validate stage forms"""
|
"""OTP Validate stage forms"""
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.core.validators import RegexValidator
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django_otp import match_token
|
from django_otp import match_token
|
||||||
|
|
||||||
from passbook.core.models import User
|
from passbook.core.models import User
|
||||||
from passbook.stages.otp_validate.models import OTPValidateStage
|
from passbook.stages.otp_validate.models import OTPValidateStage
|
||||||
|
|
||||||
OTP_CODE_VALIDATOR = RegexValidator(
|
|
||||||
r"^[0-9a-z]{6,8}$", _("Only alpha-numeric characters are allowed.")
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class ValidationForm(forms.Form):
|
class ValidationForm(forms.Form):
|
||||||
"""OTP Validate stage forms"""
|
"""OTP Validate stage forms"""
|
||||||
|
@ -19,7 +14,6 @@ class ValidationForm(forms.Form):
|
||||||
|
|
||||||
code = forms.CharField(
|
code = forms.CharField(
|
||||||
label=_("Please enter the token from your device."),
|
label=_("Please enter the token from your device."),
|
||||||
validators=[OTP_CODE_VALIDATOR],
|
|
||||||
widget=forms.TextInput(
|
widget=forms.TextInput(
|
||||||
attrs={
|
attrs={
|
||||||
"autocomplete": "off",
|
"autocomplete": "off",
|
||||||
|
|
Reference in New Issue