2018-12-14 08:49:34 +00:00
|
|
|
"""passbook multi-factor authentication engine"""
|
|
|
|
from logging import getLogger
|
|
|
|
|
|
|
|
from django.utils.translation import gettext as _
|
|
|
|
from django.views.generic import TemplateView
|
|
|
|
|
|
|
|
from passbook.lib.config import CONFIG
|
|
|
|
|
|
|
|
LOGGER = getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
class AuthenticationFactor(TemplateView):
|
|
|
|
"""Abstract Authentication factor, inherits TemplateView but can be combined with FormView"""
|
|
|
|
|
|
|
|
form = None
|
|
|
|
required = True
|
|
|
|
authenticator = None
|
2019-02-21 15:06:57 +00:00
|
|
|
pending_user = None
|
2018-12-14 08:49:34 +00:00
|
|
|
request = None
|
2019-02-23 19:41:43 +00:00
|
|
|
template_name = 'login/form_with_user.html'
|
2018-12-14 08:49:34 +00:00
|
|
|
|
|
|
|
def __init__(self, authenticator):
|
|
|
|
self.authenticator = authenticator
|
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
kwargs['config'] = CONFIG.get('passbook')
|
|
|
|
kwargs['is_login'] = True
|
|
|
|
kwargs['title'] = _('Log in to your account')
|
|
|
|
kwargs['primary_action'] = _('Log in')
|
2019-02-23 19:41:43 +00:00
|
|
|
kwargs['user'] = self.pending_user
|
2018-12-14 08:49:34 +00:00
|
|
|
return super().get_context_data(**kwargs)
|