@stamhoofd/structures
Advanced tools
Comparing version 1.4.10 to 1.4.11
@@ -27,2 +27,3 @@ import { AutoEncoder } from '@simonbackx/simple-encoding'; | ||
groups: GroupPermissions[]; | ||
hasAccess(level: PermissionLevel, groupId?: string | null): boolean; | ||
hasReadAccess(groupId?: string | null): boolean; | ||
@@ -29,0 +30,0 @@ hasWriteAccess(groupId?: string | null): boolean; |
@@ -44,21 +44,9 @@ "use strict"; | ||
} | ||
hasReadAccess(groupId = null) { | ||
if (this.level != PermissionLevel.None) { | ||
// Has read access | ||
return true; | ||
} | ||
if (!groupId) { | ||
hasAccess(level, groupId = null) { | ||
if (level == PermissionLevel.None) { | ||
// none means, none, even not none. | ||
return false; | ||
} | ||
const permission = this.groups.find(g => g.groupId === groupId); | ||
if (permission) { | ||
if (permission.level != PermissionLevel.None) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
hasWriteAccess(groupId = null) { | ||
if (this.level == PermissionLevel.Write || this.level == PermissionLevel.Full) { | ||
// Has read access | ||
if (getPermissionLevelNumber(this.level) >= getPermissionLevelNumber(level)) { | ||
// Someone with read / write access for the whole organization, also the same access for each group | ||
return true; | ||
@@ -71,3 +59,3 @@ } | ||
if (permission) { | ||
if (permission.level == PermissionLevel.Write || permission.level == PermissionLevel.Full) { | ||
if (getPermissionLevelNumber(permission.level) >= getPermissionLevelNumber(level)) { | ||
return true; | ||
@@ -78,17 +66,10 @@ } | ||
} | ||
hasReadAccess(groupId = null) { | ||
return this.hasAccess(PermissionLevel.Read, groupId); | ||
} | ||
hasWriteAccess(groupId = null) { | ||
return this.hasAccess(PermissionLevel.Write, groupId); | ||
} | ||
hasFullAccess(groupId = null) { | ||
if (this.level == PermissionLevel.Full) { | ||
// Has read access | ||
return true; | ||
} | ||
if (!groupId) { | ||
return false; | ||
} | ||
const permission = this.groups.find(g => g.groupId === groupId); | ||
if (permission) { | ||
if (permission.level == PermissionLevel.Full) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
return this.hasAccess(PermissionLevel.Full, groupId); | ||
} | ||
@@ -95,0 +76,0 @@ } |
@@ -27,2 +27,3 @@ import { AutoEncoder } from '@simonbackx/simple-encoding'; | ||
groups: GroupPermissions[]; | ||
hasAccess(level: PermissionLevel, groupId?: string | null): boolean; | ||
hasReadAccess(groupId?: string | null): boolean; | ||
@@ -29,0 +30,0 @@ hasWriteAccess(groupId?: string | null): boolean; |
@@ -39,21 +39,9 @@ import { __decorate } from "tslib"; | ||
} | ||
hasReadAccess(groupId = null) { | ||
if (this.level != PermissionLevel.None) { | ||
// Has read access | ||
return true; | ||
} | ||
if (!groupId) { | ||
hasAccess(level, groupId = null) { | ||
if (level == PermissionLevel.None) { | ||
// none means, none, even not none. | ||
return false; | ||
} | ||
const permission = this.groups.find(g => g.groupId === groupId); | ||
if (permission) { | ||
if (permission.level != PermissionLevel.None) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
hasWriteAccess(groupId = null) { | ||
if (this.level == PermissionLevel.Write || this.level == PermissionLevel.Full) { | ||
// Has read access | ||
if (getPermissionLevelNumber(this.level) >= getPermissionLevelNumber(level)) { | ||
// Someone with read / write access for the whole organization, also the same access for each group | ||
return true; | ||
@@ -66,3 +54,3 @@ } | ||
if (permission) { | ||
if (permission.level == PermissionLevel.Write || permission.level == PermissionLevel.Full) { | ||
if (getPermissionLevelNumber(permission.level) >= getPermissionLevelNumber(level)) { | ||
return true; | ||
@@ -73,17 +61,10 @@ } | ||
} | ||
hasReadAccess(groupId = null) { | ||
return this.hasAccess(PermissionLevel.Read, groupId); | ||
} | ||
hasWriteAccess(groupId = null) { | ||
return this.hasAccess(PermissionLevel.Write, groupId); | ||
} | ||
hasFullAccess(groupId = null) { | ||
if (this.level == PermissionLevel.Full) { | ||
// Has read access | ||
return true; | ||
} | ||
if (!groupId) { | ||
return false; | ||
} | ||
const permission = this.groups.find(g => g.groupId === groupId); | ||
if (permission) { | ||
if (permission.level == PermissionLevel.Full) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
return this.hasAccess(PermissionLevel.Full, groupId); | ||
} | ||
@@ -90,0 +71,0 @@ } |
{ | ||
"name": "@stamhoofd/structures", | ||
"version": "1.4.10", | ||
"version": "1.4.11", | ||
"main": "./dist/index.js", | ||
@@ -5,0 +5,0 @@ "module": "./esm/dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
433611
6284