2019-02-25 11:29:40 +00:00
|
|
|
"""OTP Factor"""
|
|
|
|
|
|
|
|
from django.db import models
|
|
|
|
from django.utils.translation import gettext as _
|
|
|
|
|
2019-10-09 10:47:14 +00:00
|
|
|
from passbook.core.models import Factor, UserSettings
|
2019-02-25 11:29:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
class OTPFactor(Factor):
|
|
|
|
"""OTP Factor"""
|
|
|
|
|
|
|
|
enforced = models.BooleanField(default=False, help_text=('Enforce enabled OTP for Users '
|
|
|
|
'this factor applies to.'))
|
|
|
|
|
2019-10-07 14:33:48 +00:00
|
|
|
type = 'passbook.factors.otp.factors.OTPFactor'
|
|
|
|
form = 'passbook.factors.otp.forms.OTPFactorForm'
|
2019-02-25 11:29:40 +00:00
|
|
|
|
2019-10-09 10:47:14 +00:00
|
|
|
def user_settings(self) -> UserSettings:
|
|
|
|
return UserSettings(_('OTP'), 'pficon-locked', 'passbook_factors_otp:otp-user-settings')
|
2019-02-25 12:20:07 +00:00
|
|
|
|
2019-02-25 11:29:40 +00:00
|
|
|
def __str__(self):
|
2019-10-07 14:33:48 +00:00
|
|
|
return f"OTP Factor {self.slug}"
|
2019-02-25 11:29:40 +00:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
|
|
|
verbose_name = _('OTP Factor')
|
|
|
|
verbose_name_plural = _('OTP Factors')
|