From de475934a24e89bc4df47be0cfee879672f48f33 Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Tue, 7 Jul 2026 20:08:55 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8(backend)=20expose=20is=5Fauthenticate?= =?UTF-8?q?d=20in=20the=20LiveKit=20token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/backend/core/tests/rooms/test_api_rooms_retrieve.py | 2 +- src/backend/core/utils.py | 6 +++++- .../features/rooms/utils/getParticipantIsAuthenticated.ts | 8 ++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 src/frontend/src/features/rooms/utils/getParticipantIsAuthenticated.ts diff --git a/src/backend/core/tests/rooms/test_api_rooms_retrieve.py b/src/backend/core/tests/rooms/test_api_rooms_retrieve.py index d27b13bf..e5c3fc46 100644 --- a/src/backend/core/tests/rooms/test_api_rooms_retrieve.py +++ b/src/backend/core/tests/rooms/test_api_rooms_retrieve.py @@ -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 diff --git a/src/backend/core/utils.py b/src/backend/core/utils.py index 02d609c2..79a70ad3 100644 --- a/src/backend/core/utils.py +++ b/src/backend/core/utils.py @@ -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", + } ) ) diff --git a/src/frontend/src/features/rooms/utils/getParticipantIsAuthenticated.ts b/src/frontend/src/features/rooms/utils/getParticipantIsAuthenticated.ts new file mode 100644 index 00000000..9b55dcde --- /dev/null +++ b/src/frontend/src/features/rooms/utils/getParticipantIsAuthenticated.ts @@ -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' +}