Repository navigation
feat: system chat user permission - #7802
Merged
Merged
Conversation
shaohuzhang1
commented
Nov 10, 2026
| <ButtonChangeUserPassword v-if="perm.system.chatUser.edit()" :user="row" @refresh="loadChatUsers(false)" /> | ||
| <!-- 更多 --> | ||
| <MkTableMoreDropdown> | ||
| <!-- 配额设置 --> |
Contributor
Author
There was a problem hiding this comment.
Review of the diff
-<ButtonChangeUserPassword :user="row" @refresh="loadChatUsers(false)" />
+<ButtonChangeUserPassword v-if="perm.system.chatUser.edit()" :user="row" @refresh="loadChatUsers(false)" />1. Correctness / API assumptions
edit()is being invoked per row render. Ifperm.system.chatUser.editis a boolean/computed ref rather than a function, this will throw (... is not a function) or silently misbehave. Confirm it is a function everywhere else (other files/lines in this component) — the same permission is likely used asperm.system.chatUser.edit(no parentheses) elsewhere, which would be an inconsistency.permmust be reactive (e.g. areactive/computedstore) for thev-ifto re-evaluate after permissions are loaded asynchronously. If it's a plain object populated after mount, rows rendered before permission load will keep showing/hiding the button incorrectly.v-ifon a component is fine (it unmounts the component, avoids the:userprop binding and internal watchers). Preferv-ifoverv-showfor permission gating. Nokeyneeded.
2. Permission semantics (most important)
- Using
chatUser.editfor "change user password" may be wrong. Resetting/changing another user's password is a more sensitive operation and often has its own permission (e.g.chatUser.resetPassword,chatUser.changePassword, or admin-only). Using the generic edit permission can both over-grant (editors can reset passwords) and under-grant (a support role that may reset passwords but can't edit profiles). - Front-end
v-ifis UX only, not security. Verify the backend endpoint enforcing this action also checks the same permission; otherwise this change is cosmetic. - Inconsistency within the action column. The sibling
MkTableMoreDropdown(quota settings, etc.) presumably also needs permission gating. If only this button is gated, the column becomes inconsistent — audit the whole cell, and consider hiding the entire "操作" (actions) column when the user has none of the permissions.
3. Performance / readability
- The predicate is global, not per-row, yet it is evaluated for every row on every re-render. Hoist it:
const canEditChatUser = computed(() => perm.system.chatUser.edit())
<ButtonChangeUserPassword v-if="canEditChatUser" :user="row" @refresh="loadChatUsers(false)" />
- Alternatively, if this pattern repeats, introduce a
v-permission="'system:chatUser:edit'"directive or ahasPerm()helper for consistency across the codebase.
4. Line length / lint
- The new line is ~123 characters including indentation; if the project uses Prettier/ESLint with a 120-char limit (common), CI will fail formatting. The multi-line form above avoids this.
5. Minor
- The hunk header (
-256,7 +256,7) matches the shown context (7 old / 7 new lines) — no count mismatch. @refresh="loadChatUsers(false)"is an inline handler expression: it works, but a clearer form is@refresh="() => loadChatUsers(false)"(same behavior, no ambiguity about the arguments).- The Chinese comments are fine for the codebase, but ensure the
<!-- 修改用户密码 -->comment is updated/kept adjacent to the gated element (it is).
Suggested final version
<!-- 修改用户密码 -->
<ButtonChangeUserPassword
v-if="canEditChatUser"
:user="row"
@refresh="loadChatUsers(false)"
/>plus
const canEditChatUser = computed(() => perm.system.chatUser.edit())and confirm (a) edit is a function, (b) it's the intended permission for password changes, and (c) the backend enforces it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: system chat user permission