Skip to content

Commit

Permalink
Merge pull request #140 from callmeehko/main
Browse files Browse the repository at this point in the history
fixed issue where server members could edit roles even without permission
  • Loading branch information
SupertigerDev authored Feb 2, 2025
2 parents 543ba17 + 624af22 commit 856180a
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/components/floating-profile/FloatingProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import Button from "../ui/Button";
import { FlexRow } from "../ui/Flexbox";
import { emitDrawerGoToMain } from "@/common/GlobalEvents";
import { emojiToUrl } from "@/common/emojiToUrl";
import { ROLE_PERMISSIONS } from "@/chat-api/Bitwise";

interface Props {
dmPane?: boolean;
Expand Down Expand Up @@ -198,6 +199,11 @@ const DesktopProfileFlyout = (props: {
? serverMembers.get(props.serverId, props.userId)
: undefined;

const accountMember = () =>
props.serverId
? serverMembers.get(props.serverId, account.user()?.id!)
: undefined;

createEffect(
on(
() => props.userId,
Expand Down Expand Up @@ -437,12 +443,14 @@ const DesktopProfileFlyout = (props: {
</div>
)}
</For>
<div
class={classNames(styles.roleContainer, styles.selectable)}
onClick={showRoleModal}
>
<Icon name="add" size={14} />
</div>
<Show when={accountMember()?.hasPermission(ROLE_PERMISSIONS.MANAGE_ROLES)}>
<div
class={classNames(styles.roleContainer, styles.selectable)}
onClick={showRoleModal}
>
<Icon name="add" size={14} />
</div>
</Show>
</div>
</Show>

Expand Down

0 comments on commit 856180a

Please sign in to comment.