diff --git a/CHANGELOG.md b/CHANGELOG.md index 066cbdd..bcc781e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # 更新日志 + +## [v1.2.2](https://github.com/buession/buession-shiro/releases/tag/1.2.2)(2024-01-05) + +### ⭐ 新特性 + +- 新增方法 hasAllPermissions 判断是否具有所有的权限 + + ## [v1.2.1](https://github.com/buession/buession-shiro/releases/tag/1.2.1)(2023-08-25) ### 🐞 BUG 修复 diff --git a/package.json b/package.json index 435eeca..2fb710f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@buession/shiro", "alias": "shiro", - "version": "v1.2.1", + "version": "v1.2.2", "description": "A security framework for JavaScript or TypeScript.", "homepage": "https://shirojs.buession.com/", "author": { diff --git a/src/shiro.ts b/src/shiro.ts index c559390..8cd5c58 100644 --- a/src/shiro.ts +++ b/src/shiro.ts @@ -3,7 +3,7 @@ import { PrincipalPlainObject, Principal, DefaultPrincipal } from './core/princi import { has, hasAny, hasAll } from './utils/common' export interface IShiro { - + /** * 验证是否为已认证通过的用户,不包含已记住的用户,这是与 isUser 标签方法的区别所在 * @@ -102,6 +102,16 @@ export interface IShiro { */ hasAnyPermission(permissions: string[]): boolean; + /** + * 验证用户是否具有以下所有权限 + * + * @param permissions + * 权限列表 + * + * @return 用户是否具有以下所有权限 + */ + hasAllPermissions(permissions: string[]): boolean; + /** * 验证用户是否具有以下所有权限 * @@ -256,8 +266,20 @@ export class Shiro implements IShiro { * * @return 用户是否具有以下所有权限 */ - hasPermissionsAll(permissions: string[]): boolean { + hasAllPermissions(permissions: string[]): boolean { return this.isAuthenticated() && (has(this.principal.getPermissions(), ALL_PERMISSION) || hasAll(this.principal.getPermissions(), permissions)); } + /** + * 验证用户是否具有以下所有权限 + * + * @param permissions + * 权限列表 + * + * @return 用户是否具有以下所有权限 + */ + hasPermissionsAll(permissions: string[]): boolean { + return this.hasAllPermissions(permissions); + } + } \ No newline at end of file