befly 1.2.3 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/main.js +9 -1
  2. package/package.json +2 -2
package/main.js CHANGED
@@ -451,7 +451,15 @@ class Befly {
451
451
  });
452
452
  }
453
453
 
454
- if (api.auth && api.auth !== true && ctx.user.role !== api.auth) {
454
+ // 如果为字符串,则判断是否等于角色类型
455
+ if (isType(api.auth, 'string') && api.auth !== ctx.user?.role_type) {
456
+ return Response.json(RNo('没有权限'), {
457
+ headers: corsOptions.headers
458
+ });
459
+ }
460
+
461
+ // 如果为数组,则判断角色是否在数组中
462
+ if (isType(api.auth, 'array') && !api.auth.includes(ctx.user?.role)) {
455
463
  return Response.json(RNo('没有权限'), {
456
464
  headers: corsOptions.headers
457
465
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "befly",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "Buma - 为 Bun 专属打造的 API 接口框架核心引擎",
5
5
  "type": "module",
6
6
  "private": false,
@@ -49,5 +49,5 @@
49
49
  "README.md",
50
50
  "vitest.config.js"
51
51
  ],
52
- "gitHead": "092063519e02232d1f60ccf7aa83978f96b940f7"
52
+ "gitHead": "2615f45da0551949dee6f75123c54259b91c05ef"
53
53
  }