Skip to content

Commit

Permalink
修复所有权限标识符错误的 BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
yong.teng committed Feb 3, 2023
1 parent 74a309a commit 0069fad
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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 修复

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion src/core/constants.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const ALL_PERMISSION = ':';
export const ALL_PERMISSION = '*:*';
1 change: 1 addition & 0 deletions src/core/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type Un = undefined | null;
26 changes: 11 additions & 15 deletions src/utils/common.ts
Original file line number Diff line number Diff line change
@@ -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;
}
return false;
}

0 comments on commit 0069fad

Please sign in to comment.