This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
authentik/passbook/factors/base.py

33 lines
1.1 KiB
Python
Raw Normal View History

"""passbook multi-factor authentication engine"""
2019-10-07 14:33:48 +00:00
from django.forms import ModelForm
from django.http import HttpRequest
from django.utils.translation import gettext as _
from django.views.generic import TemplateView
2019-10-07 14:33:48 +00:00
from passbook.core.models import User
from passbook.factors.view import AuthenticationView
from passbook.lib.config import CONFIG
class AuthenticationFactor(TemplateView):
"""Abstract Authentication factor, inherits TemplateView but can be combined with FormView"""
2019-10-07 14:33:48 +00:00
form: ModelForm = None
required: bool = True
authenticator: AuthenticationView
pending_user: User
2019-10-07 14:33:48 +00:00
request: HttpRequest = None
2019-12-31 11:51:16 +00:00
template_name = "login/form_with_user.html"
2019-10-07 14:33:48 +00:00
def __init__(self, authenticator: AuthenticationView):
self.authenticator = authenticator
self.pending_user = None
def get_context_data(self, **kwargs):
2019-12-31 11:51:16 +00:00
kwargs["config"] = CONFIG.y("passbook")
kwargs["is_login"] = True
kwargs["title"] = _("Log in to your account")
kwargs["primary_action"] = _("Log in")
kwargs["user"] = self.pending_user
return super().get_context_data(**kwargs)