return authentik launch URL
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
@ -8,6 +8,7 @@ from django.core.cache import cache
|
|||||||
from django.db.models import QuerySet
|
from django.db.models import QuerySet
|
||||||
from django.db.models.functions import ExtractHour
|
from django.db.models.functions import ExtractHour
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
|
from django.urls import reverse
|
||||||
from drf_spectacular.types import OpenApiTypes
|
from drf_spectacular.types import OpenApiTypes
|
||||||
from drf_spectacular.utils import OpenApiParameter, OpenApiResponse, extend_schema
|
from drf_spectacular.utils import OpenApiParameter, OpenApiResponse, extend_schema
|
||||||
from guardian.shortcuts import get_objects_for_user
|
from guardian.shortcuts import get_objects_for_user
|
||||||
@ -65,10 +66,12 @@ class ApplicationSerializer(ModelSerializer):
|
|||||||
|
|
||||||
def get_launch_url(self, app: Application) -> str | None:
|
def get_launch_url(self, app: Application) -> str | None:
|
||||||
"""Allow formatting of launch URL"""
|
"""Allow formatting of launch URL"""
|
||||||
user = None
|
return reverse(
|
||||||
if "request" in self.context:
|
"authentik_core:application-launch",
|
||||||
user = self.context["request"].user
|
kwargs={
|
||||||
return app.get_launch_url(user)
|
"application_slug": app.slug,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs) -> None:
|
def __init__(self, *args, **kwargs) -> None:
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|||||||
Reference in New Issue
Block a user