From 7caa78e345cf6b9c4c57b81a49baee4ed21f9b4c Mon Sep 17 00:00:00 2001 From: juancarmore Date: Thu, 14 Aug 2025 13:53:19 +0200 Subject: [PATCH] frontend: add participantIdentity handling in token refresh and service --- .../src/lib/interceptors/http.interceptor.ts | 5 ++++- .../src/lib/pages/meeting/meeting.component.ts | 5 +++-- .../src/lib/services/participant.service.ts | 6 ++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/frontend/projects/shared-meet-components/src/lib/interceptors/http.interceptor.ts b/frontend/projects/shared-meet-components/src/lib/interceptors/http.interceptor.ts index d9cbf29..e6201af 100644 --- a/frontend/projects/shared-meet-components/src/lib/interceptors/http.interceptor.ts +++ b/frontend/projects/shared-meet-components/src/lib/interceptors/http.interceptor.ts @@ -48,8 +48,11 @@ export const httpInterceptor: HttpInterceptorFn = (req: HttpRequest, ne const roomId = roomService.getRoomId(); const secret = roomService.getRoomSecret(); const participantName = participantTokenService.getParticipantName(); + const participantIdentity = participantTokenService.getParticipantIdentity(); - return from(participantTokenService.refreshParticipantToken({ roomId, secret, participantName })).pipe( + return from( + participantTokenService.refreshParticipantToken({ roomId, secret, participantName, participantIdentity }) + ).pipe( switchMap(() => { console.log('Participant token refreshed'); return next(req); diff --git a/frontend/projects/shared-meet-components/src/lib/pages/meeting/meeting.component.ts b/frontend/projects/shared-meet-components/src/lib/pages/meeting/meeting.component.ts index 36547a4..da5a985 100644 --- a/frontend/projects/shared-meet-components/src/lib/pages/meeting/meeting.component.ts +++ b/frontend/projects/shared-meet-components/src/lib/pages/meeting/meeting.component.ts @@ -372,7 +372,7 @@ export class MeetingComponent implements OnInit { // Update participant role const { participantIdentity, newRole, secret } = event as MeetParticipantRoleUpdatedPayload; - if (participantIdentity === this.localParticipant!.name) { + if (participantIdentity === this.localParticipant!.identity) { if (!secret) return; this.roomSecret = secret; @@ -382,7 +382,8 @@ export class MeetingComponent implements OnInit { await this.participantService.refreshParticipantToken({ roomId: this.roomId, secret, - participantName: this.participantName + participantName: this.participantName, + participantIdentity }); this.localParticipant!.meetRole = newRole; diff --git a/frontend/projects/shared-meet-components/src/lib/services/participant.service.ts b/frontend/projects/shared-meet-components/src/lib/services/participant.service.ts index e541888..8f5f85f 100644 --- a/frontend/projects/shared-meet-components/src/lib/services/participant.service.ts +++ b/frontend/projects/shared-meet-components/src/lib/services/participant.service.ts @@ -11,6 +11,7 @@ export class ParticipantService { protected readonly PARTICIPANTS_API = `${HttpService.INTERNAL_API_PATH_PREFIX}/participants`; protected participantName?: string; + protected participantIdentity?: string; protected role: ParticipantRole = ParticipantRole.SPEAKER; protected permissions?: ParticipantPermissions; @@ -32,6 +33,10 @@ export class ParticipantService { return this.participantName; } + getParticipantIdentity(): string | undefined { + return this.participantIdentity; + } + /** * Generates a participant token and extracts role/permissions * @@ -71,6 +76,7 @@ export class ParticipantService { const decodedToken = getValidDecodedToken(token); const metadata = decodedToken.metadata as MeetTokenMetadata; + this.participantIdentity = decodedToken.sub; this.role = metadata.selectedRole; const openviduPermissions = metadata.roles.find((r) => r.role === this.role)!.permissions; this.permissions = {