Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ui/src/views/application-detail/chat-user/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ onMounted(() => loadChatUserGroups())
<!-- 搜索对话用户 -->
<MkComplexSearch :fields="searchFields" @change="handleSearchChange" />
<!-- 设置用户组自动授权 -->
<div v-if="applicationchatUserPermission('chatUserEdit')" class="flex-align-center shrink-0 gap-2">
<div class="flex-align-center shrink-0 gap-2">
<span>自动授权</span>
<el-switch :model-value="currentGroup.is_auth" size="small" @change="handleAutoAuthorizationChange" />
<el-switch :disabled="!applicationchatUserPermission('chatUserEdit')" :model-value="currentGroup.is_auth" size="small" @change="handleAutoAuthorizationChange" />
</div>
</div>
<!-- 保存对话用户授权 -->

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No syntax/logic error is obvious in this diff, but there are a few review points:

  1. Permission behavior changed from “hidden” to “visible but disabled”

    • Before: unauthorized users did not see the auto-authorization switch.
    • After: everyone sees the switch, but unauthorized users cannot interact with it.
    • This may be intentional, but it also exposes the current currentGroup.is_auth state to users without chatUserEdit. If that state should not be visible, keep v-if or combine both:
      <div v-if="applicationchatUserPermission('chatUserEdit')" ...>
      If the disabled state is desired for UX consistency, the current approach is acceptable.
  2. Frontend permission is not security

    • :disabled only prevents UI interaction. handleAutoAuthorizationChange and the backend API must still enforce chatUserEdit. Do not rely on the disabled switch for authorization.
  3. Add a guard in the handler

    • Even with disabled, it is safer to guard the mutation handler:
      const handleAutoAuthorizationChange = (value: boolean) => {
        if (!applicationchatUserPermission('chatUserEdit')) return
        // ...
      }
  4. Avoid repeated permission function calls in the template

    • If applicationchatUserPermission is non-trivial or depends on reactive state, use a computed:
      const canEditChatUser = computed(() =>
        applicationchatUserPermission('chatUserEdit')
      )
      <el-switch :disabled="!canEditChatUser" ... />
    • Ensure the permission check is reactive; otherwise the disabled state may not update when permissions change.
  5. Consider boolean normalization

    • If currentGroup.is_auth can be undefined/null, use:
      :model-value="!!currentGroup?.is_auth"
      This avoids unexpected switch state.
  6. UX/accessibility

    • A disabled control without explanation can confuse users. If you keep it visible, consider a tooltip such as “You do not have permission to edit this setting.”

Overall: the diff is valid, but the main concerns are permission visibility, backend enforcement, and handler-side authorization guarding.

Expand Down
Loading