We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
当user.roles为空数组的时候 我给Ptl 增加auths: { roles: ["1"] } 不会触发校验是正常的吗
Ptl
The text was updated successfully, but these errors were encountered:
如果用户的roles为空 就算协议文件定义了roles也能让用户请求成功 改成这样会不会好一点
const userRoles = node.userRoles ?? []; if (type === "SOME") { const hasRole = roles.some((role) => userRoles.includes(role)); if (!hasRole) { await node.error( new TsrpcError({ message: "您没有权限操作。", code: "NOT_PERMISSION", type: TsrpcErrorType.ApiError, }) ); } } else if (type === "EVERY") { const mustRole = roles.every((role) => userRoles.includes(role)); if (!mustRole) { await node.error( new TsrpcError({ message: "您没有权限执行此操作。", code: "NOT_PERMISSION", type: TsrpcErrorType.ApiError, }) ); } }
Sorry, something went wrong.
No branches or pull requests
当user.roles为空数组的时候 我给
Ptl
增加auths: { roles: ["1"] } 不会触发校验是正常的吗The text was updated successfully, but these errors were encountered: