From 0069fadaf087fa8e8d07e15d1dab87f419510b53 Mon Sep 17 00:00:00 2001 From: "yong.teng" Date: Fri, 3 Feb 2023 22:47:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=80=E6=9C=89=E6=9D=83?= =?UTF-8?q?=E9=99=90=E6=A0=87=E8=AF=86=E7=AC=A6=E9=94=99=E8=AF=AF=E7=9A=84?= =?UTF-8?q?=20BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 8 +++++++- package.json | 2 +- src/core/constants.ts | 2 +- src/core/types.ts | 1 + src/utils/common.ts | 26 +++++++++++--------------- 5 files changed, 21 insertions(+), 18 deletions(-) create mode 100644 src/core/types.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index f3892fd..976ab26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,13 @@ # 更新日志 +## [v1.1.3](https://github.com/buession/buession-shiro/releases/tag/1.1.3)(2023-02-03) -## v1.1.2 +### 🐞 BUG 修复 + +- 修复所有权限标识符错误的 BUG + + +## [v1.1.2](https://github.com/buession/buession-shiro/releases/tag/1.1.1)(2023-02-01) ### 🐞 BUG 修复 diff --git a/package.json b/package.json index 7c94fc8..8595bf0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@buession/shiro", "alias": "shiro", - "version": "v1.1.2", + "version": "v1.1.3", "description": "A security framework for JavaScript or TypeScript.", "homepage": "https://shirojs.buession.com/", "author": { diff --git a/src/core/constants.ts b/src/core/constants.ts index 7ab8977..ac7912b 100644 --- a/src/core/constants.ts +++ b/src/core/constants.ts @@ -1 +1 @@ -export const ALL_PERMISSION = ':'; +export const ALL_PERMISSION = '*:*'; diff --git a/src/core/types.ts b/src/core/types.ts new file mode 100644 index 0000000..dc97112 --- /dev/null +++ b/src/core/types.ts @@ -0,0 +1 @@ +export type Un = undefined | null; diff --git a/src/utils/common.ts b/src/utils/common.ts index 8a7fade..e89735a 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -1,21 +1,17 @@ -export const hasAny = (data: string[] | null | undefined, value: any): boolean => { - if (data === null || data === undefined) { - return false; - } +import { Un } from "@/core/types"; - return data.indexOf(value) >= 0; +export const hasAny = (data: string[] | Un, value: any): boolean => { + return Array.isArray(data) && data.indexOf(value) >= 0; } -export const hasAll = (data: string[] | null | undefined, values: any[] | null | undefined): boolean => { - if ((data === null || data === undefined) || (values === null || values === undefined || values.length === 0)) { - return false; - } - - for (let i = 0; i < values.length; i++) { - if (data.indexOf(values[i]) < 0) { - return false; +export const hasAll = (data: string[] | Un, values: any[] | Un): boolean => { + if (Array.isArray(data) && (Array.isArray(values) && values.length > 0)) { + for (let i = 0; i < values.length; i++) { + if (data.indexOf(values[i]) >= 0) { + return true; + } } } - return true; -} \ No newline at end of file + return false; +}