frontend: Update participant role retrieval to use room role and permissions endpoint

This commit is contained in:
juancarmore 2025-04-12 13:46:25 +02:00
parent 743d3d514d
commit 5570b30686
2 changed files with 12 additions and 10 deletions

View File

@ -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' } });

View File

@ -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<ParticipantRole> {
getRoomRoleAndPermissions(roomId: string, secret: string): Promise<MeetRoomRoleAndPermissions> {
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<RecordingInfo> {
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<RecordingInfo> {