feat(kanidm): Use an async function to get the data

This commit is contained in:
Tom Hubrecht 2024-09-24 14:30:33 +02:00
parent b5cedebda1
commit a9d369d55d
Signed by: thubrecht
SSH key fingerprint: SHA256:r+nK/SIcWlJ0zFZJGHtlAoRwq1Rm+WcKAm5ADYMoQPc

View file

@ -88,12 +88,13 @@ class User(AbstractUser):
# accepted_terms = models.ManyToManyField(TermsAndConditions) # accepted_terms = models.ManyToManyField(TermsAndConditions)
@cached_property @cached_property
def kanidm(self) -> Optional[KanidmProfile]: @async_to_sync
async def kanidm(self) -> Optional[KanidmProfile]:
try: try:
radius_data = async_to_sync(client.get_radius_token)(self.username).data radius_data = (await client.get_radius_token(self.username)).data
return KanidmProfile( return KanidmProfile(
person=async_to_sync(client.person_account_get)(self.username), person=(await client.person_account_get(self.username)),
radius_secret=radius_data and radius_data.get("secret"), radius_secret=radius_data and radius_data.get("secret"),
) )
except NoMatchingEntries: except NoMatchingEntries: