跳到正文
Skillpedia
安全25k · #10107

nocobase-app-plugin-users

它能做什么

这项技能将 NocoBase Users 插件集成到应用中,并基于其 API 构建用户管理页面。适合管理应用中账户归属的管理员和开发者。

适用场景

  • ✓当你想要一个管理页面,用于创建、停用或重置用户账户时。
  • ✓当其他插件需要在用户管理中添加自己的角色时。
  • ✓当你需要配置 users 插件的权限时。

技能链接

https://github.com/nocobase/nocobase/blob/v3-develop/packages/plugins/app-plugin-users/skills/nocobase-app-plugin-users/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/nocobase/nocobase/blob/v3-develop/packages/plugins/app-plugin-users/skills/nocobase-app-plugin-users/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请帮我为 NocoBase 应用添加用户管理页面,让管理员可以邀请用户并停用账户。”

每周 5 个新技能,1 分钟读完。

工作原理

AI 会注册该插件,并基于其 API 构建页面,支持列出、创建、更新、停用和重置操作。账户和会话的存储仍由身份验证插件负责。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

User Management App Plugin

Use this Skill when an application needs user management, or when another plugin needs to expose application-specific roles in user management. Do not use it to modify the Users plugin source or to replace Authentication's user, account, or Session storage.

Public surfaces

  • Client registration factory and UsersClientOptions: @nocobase/app-plugin-users/client. It contributes only the public invitation page at /invite/:token; there is no user management page.
  • Typed API client: UsersClient and its types from @nocobase/app-plugin-users/client/user-client.
  • Server contracts: userManagementServiceToken, userRoleScopeRegistryToken, UserRoleScope, and related types from @nocobase/app-plugin-users/server/tokens.
  • HTTP API: GET /api/users (page, pageSize, q, status, roleScope, role, sort=name, order=asc|desc; answers { data, meta: { page, pageSize, total } }), GET /api/users/options, GET /api/users/:userId (latest managed profile and role scopes, requires user/read, 404 for absent accounts), POST /api/users, PATCH /api/users/:userId, DELETE /api/users/:userId?confirm=true, POST /api/users/:userId/disable|enable|resetPassword|revokeSessions, and PUT /api/users/:userId/roleScopes/:scope. The running application documents each one, with request and response schemas, at /api/swagger/docs (JSON at /api/swagger) under the Users tag. Failures use the standard error body; branch on error.reason, such as USER_NOT_FOUND, SELF_DELETE_NOT_ALLOWED, LAST_ASSIGNMENT or USER_EMAIL_CONFLICT.

UsersClient.update(userId, { name?, username?, email?, roleScopes? }) supports one atomic editor Save. Profile fields require update; submitted roleScopes additionally require assign-role. A roles-only payload requires assign-role without update. The service validates scope values, runs each applicable target-account guard, and commits profile changes and all submitted scope replacements in the caller-owned transaction, notifying permission clients only after commit. Omitted scopes are preserved. Keep the existing per-scope PUT for callers needing only one scope. Do not implement a combined Save as sequential profile and role requests: a later failure would leave a partially saved account.

Every HTTP route requires Authentication and Authorization. Routes check the user record type with the applicable action from read, create, update, disable, enable, assign-role, reset-password, revoke-sessions or delete. Account creation checks both create and assign-role. delete is permitted only while an application role scope can clean a deleted user up.

Register the plugin

  1. Register Authentication, Authorization, and then Users in the App's Client and Server plugin arrays. The Client factory takes no placement options: users().
  2. Grant only the user actions those roles need, on { type: 'user', id: '*' } because user is a record type. The plugin creates no roles and grants no access by itself.
  3. For a user management page, build it in the App on UsersClient and declare it among the App's own routes with the page access it needs; the plugin ships none.

The invitation page reports results through useToaster() from @nocobase/app-client, so the App needs the @nocobase/app-client that exports it and registers a toaster service, as the templates do: client/lib/toaster.ts from the template, and this.app.container.instance(toasterToken, createToaster()) in the register() of client/service-provider.ts, with the Toaster component mounted in client/react-providers.ts. Without the registration nothing throws, but its toasts are only logged to the browser console.

The default app permission-set scope is supplied by Users whenever the Authorization plugin's authorizationToken is available. Do not copy a user-roles Provider into an application. Set users.permissionSets: false to replace the default with an application-owned scope.

Add an application role scope

Resolve userRoleScopeRegistryToken in an application or business plugin ServiceProvider and register one UserRoleScope during boot(). The scope owns its available options, current assignment lookup, role filtering, atomic replacement, and any disable guard. Unregister it during shutdown().

Use the DatabaseConnection passed to each scope method. This is the caller-owned transaction used to keep account cr

常见问题

它会替换登录系统吗?

不会。账户和会话仍由身份验证插件保存。

它默认包含管理页面吗?

不包含。插件只添加一个公开的邀请页面,管理页面需要你自己构建。

应用可以添加自己的角色吗?

可以,通过应用或其他插件提供的角色范围契约。

详情

作者的原始描述

Integrate the Users plugin into a NocoBase App, build a user management page on its API and configure its permissions, or add an application-owned role scope through the public Server contracts.

repo: nocobase/nocobase

热度

GitHub 星标
25k
排名
#10107
许可证
—
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能