Skip to content

Commit

Permalink
core: add None check to a device's extra_description (#11904)
Browse files Browse the repository at this point in the history
  • Loading branch information
gergosimonyi authored Nov 4, 2024
1 parent 364a9a1 commit 74648df
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion authentik/core/api/devices.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Authenticator Devices API Views"""

from django.utils.translation import gettext_lazy as _
from drf_spectacular.types import OpenApiTypes
from drf_spectacular.utils import OpenApiParameter, extend_schema
from rest_framework.fields import (
Expand Down Expand Up @@ -40,7 +41,11 @@ def get_type(self, instance: Device) -> str:
def get_extra_description(self, instance: Device) -> str:
"""Get extra description"""
if isinstance(instance, WebAuthnDevice):
return instance.device_type.description
return (
instance.device_type.description
if instance.device_type
else _("Extra description not available")
)
if isinstance(instance, EndpointDevice):
return instance.data.get("deviceSignals", {}).get("deviceModel")
return ""
Expand Down

0 comments on commit 74648df

Please sign in to comment.