Skip to content

Commit

Permalink
Restrict embeds to unauthenticated shares only
Browse files Browse the repository at this point in the history
  • Loading branch information
jordan-dalby committed Nov 30, 2024
1 parent 8bcca32 commit e1ef5f0
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions client/src/components/snippets/share/ShareMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,21 @@ export const ShareMenu: React.FC<ShareMenuProps> = ({ isOpen, onClose, snippet }
)}
</button>
<button
onClick={() => handleEmbedClick(share.id)}
className="p-2 hover:bg-light-hover dark:hover:bg-dark-hover rounded-md transition-colors"
title="Embed snippet"
onClick={() => share.requires_auth === 0 && handleEmbedClick(share.id)}
className={`p-2 rounded-md transition-colors ${
share.requires_auth === 0
? 'hover:bg-light-hover dark:hover:bg-dark-hover'
: 'cursor-not-allowed'
}`}
title={share.requires_auth === 1 ? "Only unauthenticated snippets can be embedded" : "Embed snippet"}
>
<Code2 size={16} className="text-light-text dark:text-dark-text" />
<Code2
size={16}
className={share.requires_auth === 1
? "text-light-text-secondary dark:text-dark-text-secondary opacity-50"
: "text-light-text dark:text-dark-text"
}
/>
</button>
<button
onClick={() => handleDeleteShare(share.id)}
Expand Down Expand Up @@ -268,4 +278,4 @@ export const ShareMenu: React.FC<ShareMenuProps> = ({ isOpen, onClose, snippet }
)}
</>
);
};
}

0 comments on commit e1ef5f0

Please sign in to comment.