用户与权限 GraphQL API
🌐 Users & Permissions GraphQL API
Page summary:
“用户与权限”功能提供用于身份验证、用户管理和基于角色的访问的 GraphQL 查询和变更。
此页面记录了用户与权限功能提供的所有 GraphQL 查询和变更。有关配置详情,请参见主 用户与权限页面。
🌐 This page documents all GraphQL queries and mutations provided by the Users & Permissions feature. For configuration details, see the main Users & Permissions page.
身份验证
🌐 Authentication
身份验证变更处理登录、注册和密码管理。公共变更不需要授权头。
🌐 Authentication mutations handle login, registration, and password management. Public mutations do not require an Authorization header.
登录
🌐 Login
login 突变用于验证用户并返回 JWT:
🌐 The login mutation authenticates a user and returns a JWT:
mutation {
login(input: { identifier: "user@example.com", password: "yourPassword" }) {
jwt
user {
id
documentId
username
email
confirmed
blocked
}
}
}
输入类型 UsersPermissionsLoginInput:
🌐 Input type UsersPermissionsLoginInput:
identifier(字符串!):电子邮件或用户名password(字符串!)provider(字符串,默认为 "local")
返回 UsersPermissionsLoginPayload:jwt(字符串),user(UsersPermissionsMe)
🌐 Returns UsersPermissionsLoginPayload: jwt (String), user (UsersPermissionsMe)
认证:公开
🌐 Auth: Public
注册
🌐 Register
register 突变会创建一个新的用户账户并返回一个 JWT:
🌐 The register mutation creates a new user account and returns a JWT:
mutation {
register(input: { username: "newuser", email: "new@example.com", password: "Password123!" }) {
jwt
user {
id
documentId
username
email
}
}
}
输入类型 UsersPermissionsRegisterInput:
🌐 Input type UsersPermissionsRegisterInput:
username(字符串!)email(字符串!)password(字符串!)
返回 UsersPermissionsLoginPayload
🌐 Returns UsersPermissionsLoginPayload
认证:公开
🌐 Auth: Public
默认情况下仅接受 username、email 和 password。其他字段需要 register.allowedFields 配置。
🌐 Only username, email, and password are accepted by default. Additional fields require register.allowedFields configuration.
忘记密码
🌐 Forgot password
forgotPassword 突变向用户发送密码重置电子邮件:
🌐 The forgotPassword mutation sends a password reset email to the user:
mutation {
forgotPassword(email: "user@example.com") {
ok
}
}
输入:email(字符串!),作为直接参数传递,而不是封装在输入类型中。
🌐 Input: email (String!), passed as a direct argument, not wrapped in an input type.
返回 UsersPermissionsPasswordPayload:ok(布尔值!)
🌐 Returns UsersPermissionsPasswordPayload: ok (Boolean!)
认证:公开
🌐 Auth: Public
重置密码
🌐 Reset password
resetPassword 突变使用通过电子邮件收到的令牌设置新密码:
🌐 The resetPassword mutation sets a new password using the token received by email:
mutation {
resetPassword(code: "resetTokenFromEmail", password: "NewPassword123!", passwordConfirmation: "NewPassword123!") {
jwt
user {
id
username
email
}
}
}
输入(直接参数):
🌐 Input (direct arguments):
code(字符串!):从电子邮件重置令牌password(字符串!)passwordConfirmation(字符串!)
返回 UsersPermissionsLoginPayload
🌐 Returns UsersPermissionsLoginPayload
认证:公开
🌐 Auth: Public
更改密码
🌐 Change password
changePassword 突变会更新当前已认证用户的密码:
🌐 The changePassword mutation updates the password for the currently authenticated user:
mutation {
changePassword(currentPassword: "OldPassword123!", password: "NewPassword456!", passwordConfirmation: "NewPassword456!") {
jwt
user {
id
username
email
}
}
}
需要带有 Bearer 令牌的授权头。
🌐 Requires an Authorization header with a Bearer token.
输入(直接参数):
🌐 Input (direct arguments):
currentPassword(字符串!)password(字符串!)passwordConfirmation(字符串!)
返回 UsersPermissionsLoginPayload
🌐 Returns UsersPermissionsLoginPayload
认证:已认证
🌐 Auth: Authenticated
电子邮件确认
🌐 Email confirmation
emailConfirmation 突变使用通过电子邮件收到的令牌来确认用户的电子邮件地址:
🌐 The emailConfirmation mutation confirms a user's email address using the token received by email:
mutation {
emailConfirmation(confirmation: "confirmationTokenFromEmail") {
jwt
user {
id
username
email
confirmed
}
}
}