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 roomId = roomService.getRoomId();
|
||||||
const secret = roomService.getRoomSecret();
|
const secret = roomService.getRoomSecret();
|
||||||
const participantName = participantTokenService.getParticipantName();
|
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(() => {
|
switchMap(() => {
|
||||||
console.log('Participant token refreshed');
|
console.log('Participant token refreshed');
|
||||||
return next(req);
|
return next(req);
|
||||||
|
|||||||
@ -372,7 +372,7 @@ export class MeetingComponent implements OnInit {
|
|||||||
// Update participant role
|
// Update participant role
|
||||||
const { participantIdentity, newRole, secret } = event as MeetParticipantRoleUpdatedPayload;
|
const { participantIdentity, newRole, secret } = event as MeetParticipantRoleUpdatedPayload;
|
||||||
|
|
||||||
if (participantIdentity === this.localParticipant!.name) {
|
if (participantIdentity === this.localParticipant!.identity) {
|
||||||
if (!secret) return;
|
if (!secret) return;
|
||||||
|
|
||||||
this.roomSecret = secret;
|
this.roomSecret = secret;
|
||||||
@ -382,7 +382,8 @@ export class MeetingComponent implements OnInit {
|
|||||||
await this.participantService.refreshParticipantToken({
|
await this.participantService.refreshParticipantToken({
|
||||||
roomId: this.roomId,
|
roomId: this.roomId,
|
||||||
secret,
|
secret,
|
||||||
participantName: this.participantName
|
participantName: this.participantName,
|
||||||
|
participantIdentity
|
||||||
});
|
});
|
||||||
|
|
||||||
this.localParticipant!.meetRole = newRole;
|
this.localParticipant!.meetRole = newRole;
|
||||||
|
|||||||
@ -11,6 +11,7 @@ export class ParticipantService {
|
|||||||
protected readonly PARTICIPANTS_API = `${HttpService.INTERNAL_API_PATH_PREFIX}/participants`;
|
protected readonly PARTICIPANTS_API = `${HttpService.INTERNAL_API_PATH_PREFIX}/participants`;
|
||||||
|
|
||||||
protected participantName?: string;
|
protected participantName?: string;
|
||||||
|
protected participantIdentity?: string;
|
||||||
protected role: ParticipantRole = ParticipantRole.SPEAKER;
|
protected role: ParticipantRole = ParticipantRole.SPEAKER;
|
||||||
protected permissions?: ParticipantPermissions;
|
protected permissions?: ParticipantPermissions;
|
||||||
|
|
||||||
@ -32,6 +33,10 @@ export class ParticipantService {
|
|||||||
return this.participantName;
|
return this.participantName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getParticipantIdentity(): string | undefined {
|
||||||
|
return this.participantIdentity;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a participant token and extracts role/permissions
|
* Generates a participant token and extracts role/permissions
|
||||||
*
|
*
|
||||||
@ -71,6 +76,7 @@ export class ParticipantService {
|
|||||||
const decodedToken = getValidDecodedToken(token);
|
const decodedToken = getValidDecodedToken(token);
|
||||||
const metadata = decodedToken.metadata as MeetTokenMetadata;
|
const metadata = decodedToken.metadata as MeetTokenMetadata;
|
||||||
|
|
||||||
|
this.participantIdentity = decodedToken.sub;
|
||||||
this.role = metadata.selectedRole;
|
this.role = metadata.selectedRole;
|
||||||
const openviduPermissions = metadata.roles.find((r) => r.role === this.role)!.permissions;
|
const openviduPermissions = metadata.roles.find((r) => r.role === this.role)!.permissions;
|
||||||
this.permissions = {
|
this.permissions = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user