Skip to content

fix: application chat user permission error - #7939

Merged
peslyn merged 1 commit into
v3from
pr@v3@fix_application_chat_user_permission_error
Nov 16, 2026
Merged

peslyn merged 1 commit into
v3from
pr@v3@fix_application_chat_user_permission_error

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

fix: application chat user permission error

<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.

@peslyn
peslyn merged commit dbd1e6e into v3 Nov 16, 2026
3 of 4 checks passed
@peslyn
peslyn deleted the pr@v3@fix_application_chat_user_permission_error branch November 16, 2026 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants