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/core/views/overview.py

25 lines
872 B
Python
Raw Normal View History

2018-11-11 12:41:48 +00:00
"""passbook overview views"""
from django.contrib.auth.mixins import LoginRequiredMixin
from django.views.generic import TemplateView
from passbook.core.models import Application
2019-10-07 14:33:48 +00:00
from passbook.policies.engine import PolicyEngine
2018-11-11 12:41:48 +00:00
class OverviewView(LoginRequiredMixin, TemplateView):
"""Overview for logged in user, incase user opens passbook directly
and is not being forwarded"""
template_name = 'overview/index.html'
2018-11-16 10:41:14 +00:00
def get_context_data(self, **kwargs):
kwargs['applications'] = []
for application in Application.objects.all():
engine = PolicyEngine(application.policies.all())
engine.for_user(self.request.user).with_request(self.request)
engine.build()
if engine.passing:
kwargs['applications'].append(application)
2018-11-16 10:41:14 +00:00
return super().get_context_data(**kwargs)