Source code for ferrosoft.apps.ferrobase.views.session
# Copyright (c) 2025 Ferrosoft GmbH. All rights reserved.
import two_factor.views as two_factor_views
from django.contrib.auth import logout
from django.shortcuts import render
[docs]
class LoginView(two_factor_views.LoginView):
"""Two-factor login view augmented with the platform's email footer context."""
[docs]
def get_device_context_data(self, **kwargs):
"""Add ``FERROBASE_EMAIL_FOOTER`` from settings to the device context."""
from django.conf import settings
return super().get_device_context_data(**kwargs) | {
# Variable name is in line with ferrobase context processor.
"FERROBASE_EMAIL_FOOTER": getattr(settings, "EMAIL_FOOTER", []),
}
[docs]
class SetupView(two_factor_views.SetupView):
"""Two-factor setup view augmented with the platform's email footer context."""
[docs]
def get_device_context_data(self, **kwargs):
"""Add ``FERROBASE_EMAIL_FOOTER`` from settings to the device context."""
from django.conf import settings
return super().get_device_context_data(**kwargs) | {
# Variable name is in line with ferrobase context processor.
"FERROBASE_EMAIL_FOOTER": getattr(settings, "EMAIL_FOOTER", []),
}
[docs]
def logout_view(request):
"""Log the user out and render the post-logout confirmation page."""
logout(request)
return render(request, "ferrobase/session/logout.html")