openvidu-recording-improved: Remove unnecessary permissions in token creation

This commit is contained in:
juancarmore 2024-09-20 16:00:43 +02:00
parent d89aafa991
commit c9d0e375c4

View File

@ -19,14 +19,7 @@ roomController.post("/", async (req, res) => {
const at = new AccessToken(LIVEKIT_API_KEY, LIVEKIT_API_SECRET, { const at = new AccessToken(LIVEKIT_API_KEY, LIVEKIT_API_SECRET, {
identity: participantName identity: participantName
}); });
const permissions = { at.addGrant({ room: roomName, roomJoin: true, roomRecord: true });
room: roomName,
roomJoin: true,
roomAdmin: true,
roomList: true,
roomRecord: true
};
at.addGrant(permissions);
const token = await at.toJwt(); const token = await at.toJwt();
try { try {
@ -36,10 +29,10 @@ roomController.post("/", async (req, res) => {
if (!exists) { if (!exists) {
await roomService.createRoom(roomName); await roomService.createRoom(roomName);
} }
res.json({ token });
} catch (error) { } catch (error) {
console.error("Error creating room.", error); console.error("Error creating room.", error);
res.status(500).json({ errorMessage: "Error creating room" }); res.status(500).json({ errorMessage: "Error creating room" });
} }
res.json({ token });
}); });