From 5570b30686d0ed3d6cfd5bd82732ef5ef9881d35 Mon Sep 17 00:00:00 2001 From: juancarmore Date: Sat, 12 Apr 2025 13:46:25 +0200 Subject: [PATCH] frontend: Update participant role retrieval to use room role and permissions endpoint --- .../src/lib/guards/auth.guard.ts | 5 +++-- .../src/lib/services/http/http.service.ts | 17 +++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/frontend/projects/shared-meet-components/src/lib/guards/auth.guard.ts b/frontend/projects/shared-meet-components/src/lib/guards/auth.guard.ts index bd8e36e..cf81e47 100644 --- a/frontend/projects/shared-meet-components/src/lib/guards/auth.guard.ts +++ b/frontend/projects/shared-meet-components/src/lib/guards/auth.guard.ts @@ -53,7 +53,7 @@ export const checkParticipantRoleAndAuthGuard: CanActivateFn = async ( const sessionStorageService = inject(SessionStorageService); const httpService = inject(HttpService); - // Get participant role by room secret + // Get the role that the participant will have in the room based on the room ID and secret let participantRole: ParticipantRole; try { @@ -61,7 +61,8 @@ export const checkParticipantRoleAndAuthGuard: CanActivateFn = async ( const secret = contextService.getSecret(); const storageSecret = sessionStorageService.getModeratorSecret(roomId); - participantRole = await httpService.getParticipantRole(roomId, storageSecret || secret); + const roomRoleAndPermissions = await httpService.getRoomRoleAndPermissions(roomId, storageSecret || secret); + participantRole = roomRoleAndPermissions.role; } catch (error) { console.error('Error getting participant role:', error); return router.createUrlTree(['unauthorized'], { queryParams: { reason: 'unauthorized-participant' } }); diff --git a/frontend/projects/shared-meet-components/src/lib/services/http/http.service.ts b/frontend/projects/shared-meet-components/src/lib/services/http/http.service.ts index 521b7d1..e312826 100644 --- a/frontend/projects/shared-meet-components/src/lib/services/http/http.service.ts +++ b/frontend/projects/shared-meet-components/src/lib/services/http/http.service.ts @@ -1,9 +1,9 @@ -import { HttpClient, HttpHeaders } from '@angular/common/http'; +import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -import { MeetRoom, MeetRoomOptions } from 'projects/shared-meet-components/src/lib/typings/ce/room'; import { - GlobalPreferences, - ParticipantRole, + MeetRoom, + MeetRoomOptions, + MeetRoomRoleAndPermissions, MeetRoomPreferences, SecurityPreferencesDTO, TokenOptions, @@ -16,7 +16,6 @@ import { lastValueFrom } from 'rxjs'; providedIn: 'root' }) export class HttpService { - // private baseHref: string; protected API_PATH_PREFIX = 'meet/api'; protected INTERNAL_API_PATH_PREFIX = 'meet/internal-api'; protected API_V1_VERSION = 'v1'; @@ -44,9 +43,9 @@ export class HttpService { return this.getRequest(path); } - getParticipantRole(roomId: string, secret: string): Promise { + getRoomRoleAndPermissions(roomId: string, secret: string): Promise { return this.getRequest( - `${this.INTERNAL_API_PATH_PREFIX}/${this.API_V1_VERSION}/rooms/${roomId}/participant-role?secret=${secret}` + `${this.INTERNAL_API_PATH_PREFIX}/${this.API_V1_VERSION}/rooms/${roomId}/roles/${secret}` ); } @@ -124,7 +123,9 @@ export class HttpService { } stopRecording(recordingId: string): Promise { - return this.postRequest(`${this.INTERNAL_API_PATH_PREFIX}/${this.API_V1_VERSION}/recordings/${recordingId}/stop`); + return this.postRequest( + `${this.INTERNAL_API_PATH_PREFIX}/${this.API_V1_VERSION}/recordings/${recordingId}/stop` + ); } deleteRecording(recordingId: string): Promise {