(backend) expose is_authenticated in the LiveKit token

Include the is_authenticated flag on the user in the LiveKit token
and participant metadata.

The frontend needs this information (used in the next commit) to
know whether it can offer to promote a user with access to the room
admin.
This commit is contained in:
lebaudantoine
2026-07-07 20:08:55 +02:00
parent 73b2891e7c
commit de475934a2
3 changed files with 14 additions and 2 deletions
@@ -12,7 +12,7 @@ import pytest
from rest_framework.test import APIClient
from ...factories import RoomFactory, UserFactory, UserResourceAccessFactory
from ...models import RoomAccessLevel, RoleChoices
from ...models import RoleChoices, RoomAccessLevel
pytestmark = pytest.mark.django_db
+5 -1
View File
@@ -129,7 +129,11 @@ def generate_token(
.with_identity(identity)
.with_name(display_name)
.with_attributes(
{"color": color, "room_role": role }
{
"color": color,
"room_role": role,
"is_authenticated": "true" if user.is_authenticated else "false",
}
)
)
@@ -0,0 +1,8 @@
import type { Participant } from 'livekit-client'
export const getParticipantIsAuthenticated = (
participant: Participant
): boolean => {
const isAuthenticated = participant.attributes?.is_authenticated
return isAuthenticated == 'true'
}