mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-08-04 14:57:42 +00:00
fix(share): resolve role before creating shared link
Role lookup between create and grant left an orphaned link without ACL entries if getRoleByName threw — retry then hit "Share already exists" with no recovery path.
This commit is contained in:
parent
4ee3416326
commit
57f90a7242
1 changed files with 3 additions and 3 deletions
|
|
@ -111,11 +111,11 @@ router.get('/link/:conversationId', requireJwtAuth, async (req, res) => {
|
|||
router.post('/:conversationId', requireJwtAuth, checkSharedLinksAccess, async (req, res) => {
|
||||
try {
|
||||
const { targetMessageId } = req.body;
|
||||
const role = await getRoleByName(req.user.role);
|
||||
const sharedLinksPerms = role?.permissions?.[PermissionTypes.SHARED_LINKS] || {};
|
||||
const grantPublic = sharedLinksPerms[Permissions.SHARE_PUBLIC] === true;
|
||||
const created = await createSharedLink(req.user.id, req.params.conversationId, targetMessageId);
|
||||
if (created) {
|
||||
const role = await getRoleByName(req.user.role);
|
||||
const sharedLinksPerms = role?.permissions?.[PermissionTypes.SHARED_LINKS] || {};
|
||||
const grantPublic = sharedLinksPerms[Permissions.SHARE_PUBLIC] === true;
|
||||
await grantCreationPermissions(created._id, req.user.id, grantPublic);
|
||||
res.status(200).json(created);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue