frontend: Replace global preferences with security preferences in context model and service

This commit is contained in:
juancarmore 2025-03-28 18:56:05 +01:00
parent 2d82d6a96d
commit de9caec62a
3 changed files with 26 additions and 20 deletions

View File

@ -1,7 +1,7 @@
import {
GlobalPreferences,
OpenViduMeetPermissions,
ParticipantRole
ParticipantRole,
SecurityPreferencesDTO
} from 'projects/shared-meet-components/src/public-api';
export interface ContextData {
@ -13,7 +13,7 @@ export interface ContextData {
participantPermissions: OpenViduMeetPermissions;
mode: ApplicationMode;
edition: Edition;
globalPreferences?: GlobalPreferences;
securityPreferences?: SecurityPreferencesDTO;
leaveRedirectUrl: string;
parentDomain: string;
version: string;

View File

@ -25,7 +25,7 @@ export class ContextService {
},
mode: ApplicationMode.STANDALONE,
edition: Edition.CE,
globalPreferences: undefined,
securityPreferences: undefined,
leaveRedirectUrl: '',
parentDomain: '',
version: '',
@ -167,18 +167,18 @@ export class ContextService {
}
async canUsersCreateRooms(): Promise<boolean> {
await this.getGlobalPreferences();
return this.context.globalPreferences!.securityPreferences.roomCreationPolicy.allowRoomCreation;
await this.getSecurityPreferences();
return this.context.securityPreferences!.roomCreationPolicy.allowRoomCreation;
}
async isAuthRequiredToCreateRooms(): Promise<boolean> {
await this.getGlobalPreferences();
return this.context.globalPreferences!.securityPreferences.roomCreationPolicy.requireAuthentication;
await this.getSecurityPreferences();
return this.context.securityPreferences!.roomCreationPolicy.requireAuthentication;
}
async getAuthModeToEnterRoom(): Promise<AuthMode> {
await this.getGlobalPreferences();
return this.context.globalPreferences!.securityPreferences.authentication.authMode;
await this.getSecurityPreferences();
return this.context.securityPreferences!.authentication.authMode;
}
private getValidDecodedToken(token: string) {
@ -204,14 +204,13 @@ export class ContextService {
}
}
private async getGlobalPreferences() {
if (!this.context.globalPreferences) {
private async getSecurityPreferences() {
if (!this.context.securityPreferences) {
try {
// TODO: Retrieve only publicly available global preferences
this.context.globalPreferences = await this.httpService.getGlobalPreferences();
this.context.securityPreferences = await this.httpService.getSecurityPreferences();
} catch (error) {
this.log.e('Error getting global preferences', error);
throw new Error('Error getting global preferences');
this.log.e('Error getting security preferences', error);
throw new Error('Error getting security preferences');
}
}
}

View File

@ -1,7 +1,14 @@
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { OpenViduMeetRoom, OpenViduMeetRoomOptions } from 'projects/shared-meet-components/src/lib/typings/ce/room';
import { GlobalPreferences, ParticipantRole, RoomPreferences, TokenOptions, User } from '@lib/typings/ce';
import {
GlobalPreferences,
ParticipantRole,
RoomPreferences,
SecurityPreferencesDTO,
TokenOptions,
User
} from '@lib/typings/ce';
import { RecordingInfo, Room } from 'openvidu-components-angular';
import { lastValueFrom } from 'rxjs';
@ -61,12 +68,12 @@ export class HttpService {
}
/**
* Retrieves the global preferences.
* Retrieves security preferences.
*
* @returns {Promise<GlobalPreferences>} A promise that resolves to the global preferences.
*/
getGlobalPreferences(): Promise<GlobalPreferences> {
return this.getRequest(`${this.API_PATH_PREFIX}/${this.API_V1_VERSION}/preferences`);
getSecurityPreferences(): Promise<SecurityPreferencesDTO> {
return this.getRequest(`${this.API_PATH_PREFIX}/${this.API_V1_VERSION}/preferences/security`);
}
/**