frontend: add participantIdentity handling in token refresh and service
This commit is contained in:
parent
f22e0fc185
commit
7caa78e345
@ -48,8 +48,11 @@ export const httpInterceptor: HttpInterceptorFn = (req: HttpRequest<unknown>, 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);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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 = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user