@stamhoofd/backend 2.65.2 → 2.66.0
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.
- package/package.json +10 -10
- package/src/helpers/AdminPermissionChecker.ts +45 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stamhoofd/backend",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.66.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
"@simonbackx/simple-encoding": "2.19.0",
|
|
38
38
|
"@simonbackx/simple-endpoints": "1.15.0",
|
|
39
39
|
"@simonbackx/simple-logging": "^1.0.1",
|
|
40
|
-
"@stamhoofd/backend-i18n": "2.
|
|
41
|
-
"@stamhoofd/backend-middleware": "2.
|
|
42
|
-
"@stamhoofd/email": "2.
|
|
43
|
-
"@stamhoofd/models": "2.
|
|
44
|
-
"@stamhoofd/queues": "2.
|
|
45
|
-
"@stamhoofd/sql": "2.
|
|
46
|
-
"@stamhoofd/structures": "2.
|
|
47
|
-
"@stamhoofd/utility": "2.
|
|
40
|
+
"@stamhoofd/backend-i18n": "2.66.0",
|
|
41
|
+
"@stamhoofd/backend-middleware": "2.66.0",
|
|
42
|
+
"@stamhoofd/email": "2.66.0",
|
|
43
|
+
"@stamhoofd/models": "2.66.0",
|
|
44
|
+
"@stamhoofd/queues": "2.66.0",
|
|
45
|
+
"@stamhoofd/sql": "2.66.0",
|
|
46
|
+
"@stamhoofd/structures": "2.66.0",
|
|
47
|
+
"@stamhoofd/utility": "2.66.0",
|
|
48
48
|
"archiver": "^7.0.1",
|
|
49
49
|
"aws-sdk": "^2.885.0",
|
|
50
50
|
"axios": "1.6.8",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"access": "public"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "e4c406ad52c3f2018f5fbff17869a2003ec773c2"
|
|
68
68
|
}
|
|
@@ -820,21 +820,26 @@ export class AdminPermissionChecker {
|
|
|
820
820
|
const recordCategories: RecordCategory[] = [];
|
|
821
821
|
for (const organization of organizations) {
|
|
822
822
|
if (isUserManager) {
|
|
823
|
-
// If the user is a manager, we can always access all records
|
|
824
|
-
// if we ever add private records, we can exclude them here
|
|
825
823
|
for (const category of organization.meta.recordsConfiguration.recordCategories) {
|
|
826
|
-
|
|
824
|
+
if (category.checkPermissionForUserManager(level)) {
|
|
825
|
+
recordCategories.push(category);
|
|
826
|
+
}
|
|
827
827
|
}
|
|
828
|
-
continue;
|
|
829
828
|
}
|
|
830
829
|
|
|
831
830
|
const permissions = await this.getOrganizationPermissions(organization);
|
|
831
|
+
|
|
832
832
|
if (!permissions) {
|
|
833
833
|
continue;
|
|
834
834
|
}
|
|
835
835
|
|
|
836
836
|
// Now add all records of this organization
|
|
837
837
|
for (const category of organization.meta.recordsConfiguration.recordCategories) {
|
|
838
|
+
if (isUserManager && recordCategories.find(c => c.id === category.id)) {
|
|
839
|
+
// Already added
|
|
840
|
+
continue;
|
|
841
|
+
}
|
|
842
|
+
|
|
838
843
|
if (permissions.hasResourceAccess(PermissionsResourceType.RecordCategories, category.id, level)) {
|
|
839
844
|
recordCategories.push(category);
|
|
840
845
|
}
|
|
@@ -862,9 +867,14 @@ export class AdminPermissionChecker {
|
|
|
862
867
|
continue;
|
|
863
868
|
}
|
|
864
869
|
|
|
865
|
-
if (
|
|
870
|
+
if (platformPermissions?.hasResourceAccess(PermissionsResourceType.RecordCategories, category.id, level)) {
|
|
866
871
|
recordCategories.push(category);
|
|
867
872
|
}
|
|
873
|
+
else if (isUserManager) {
|
|
874
|
+
if (category.checkPermissionForUserManager(level)) {
|
|
875
|
+
recordCategories.push(category);
|
|
876
|
+
}
|
|
877
|
+
}
|
|
868
878
|
}
|
|
869
879
|
}
|
|
870
880
|
|
|
@@ -1003,10 +1013,22 @@ export class AdminPermissionChecker {
|
|
|
1003
1013
|
async getAccessibleRecordSet(member: MemberWithRegistrations, level: PermissionLevel = PermissionLevel.Read): Promise<Set<string>> {
|
|
1004
1014
|
const categories = await this.getAccessibleRecordCategories(member, level);
|
|
1005
1015
|
const set = new Set<string>();
|
|
1016
|
+
const isUserManager = this.isUserManager(member);
|
|
1006
1017
|
|
|
1007
|
-
|
|
1008
|
-
for (const
|
|
1009
|
-
|
|
1018
|
+
if (isUserManager) {
|
|
1019
|
+
for (const category of categories) {
|
|
1020
|
+
for (const record of category.getAllRecords()) {
|
|
1021
|
+
if (record.checkPermissionForUserManager(level)) {
|
|
1022
|
+
set.add(record.id);
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
else {
|
|
1028
|
+
for (const category of categories) {
|
|
1029
|
+
for (const record of category.getAllRecords()) {
|
|
1030
|
+
set.add(record.id);
|
|
1031
|
+
}
|
|
1010
1032
|
}
|
|
1011
1033
|
}
|
|
1012
1034
|
|
|
@@ -1033,17 +1055,6 @@ export class AdminPermissionChecker {
|
|
|
1033
1055
|
* Changes data inline
|
|
1034
1056
|
*/
|
|
1035
1057
|
async filterMemberData(member: MemberWithRegistrations, data: MemberWithRegistrationsBlob): Promise<MemberWithRegistrationsBlob> {
|
|
1036
|
-
const isUserManager = this.isUserManager(member);
|
|
1037
|
-
if (isUserManager) {
|
|
1038
|
-
// For the user manager, we don't delete data, because when registering a new member, it doesn't have any organizations yet...
|
|
1039
|
-
if (!(await this.canAccessMember(member, PermissionLevel.Full))) {
|
|
1040
|
-
data.details.securityCode = null;
|
|
1041
|
-
data.details.notes = null;
|
|
1042
|
-
}
|
|
1043
|
-
|
|
1044
|
-
return data;
|
|
1045
|
-
}
|
|
1046
|
-
|
|
1047
1058
|
const records = await this.getAccessibleRecordSet(member, PermissionLevel.Read);
|
|
1048
1059
|
|
|
1049
1060
|
const cloned = data.clone();
|
|
@@ -1054,6 +1065,17 @@ export class AdminPermissionChecker {
|
|
|
1054
1065
|
}
|
|
1055
1066
|
}
|
|
1056
1067
|
|
|
1068
|
+
const isUserManager = this.isUserManager(member);
|
|
1069
|
+
if (isUserManager) {
|
|
1070
|
+
// For a user manager without an organization, we don't delete data, because when registering a new member, it doesn't have any organizations yet...
|
|
1071
|
+
if (!(await this.canAccessMember(member, PermissionLevel.Full))) {
|
|
1072
|
+
cloned.details.securityCode = null;
|
|
1073
|
+
cloned.details.notes = null;
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
return cloned;
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1057
1079
|
// Has financial read access?
|
|
1058
1080
|
if (!await this.hasFinancialMemberAccess(member, PermissionLevel.Read)) {
|
|
1059
1081
|
cloned.details.requiresFinancialSupport = null;
|
|
@@ -1106,7 +1128,6 @@ export class AdminPermissionChecker {
|
|
|
1106
1128
|
const hasRecordAnswers = !!data.details.recordAnswers;
|
|
1107
1129
|
const hasNotes = data.details.notes !== undefined;
|
|
1108
1130
|
const isSetFinancialSupportTrue = data.details.shouldApplyReducedPrice;
|
|
1109
|
-
const isUserManager = this.isUserManager(member);
|
|
1110
1131
|
|
|
1111
1132
|
if (data.details.securityCode !== undefined || data.details.trackingYear !== undefined) {
|
|
1112
1133
|
const hasFullAccess = await this.canAccessMember(member, PermissionLevel.Full);
|
|
@@ -1136,7 +1157,7 @@ export class AdminPermissionChecker {
|
|
|
1136
1157
|
});
|
|
1137
1158
|
}
|
|
1138
1159
|
|
|
1139
|
-
const records =
|
|
1160
|
+
const records = await this.getAccessibleRecordSet(member, PermissionLevel.Write);
|
|
1140
1161
|
|
|
1141
1162
|
for (const [key, value] of data.details.recordAnswers.entries()) {
|
|
1142
1163
|
let name: string | undefined = undefined;
|
|
@@ -1162,7 +1183,7 @@ export class AdminPermissionChecker {
|
|
|
1162
1183
|
name = value.settings.name;
|
|
1163
1184
|
}
|
|
1164
1185
|
|
|
1165
|
-
if (!
|
|
1186
|
+
if (!records.has(key)) {
|
|
1166
1187
|
throw new SimpleError({
|
|
1167
1188
|
code: 'permission_denied',
|
|
1168
1189
|
message: `Je hebt geen toegangsrechten om het antwoord op ${name ?? 'deze vraag'} aan te passen voor dit lid`,
|
|
@@ -1172,6 +1193,8 @@ export class AdminPermissionChecker {
|
|
|
1172
1193
|
}
|
|
1173
1194
|
}
|
|
1174
1195
|
|
|
1196
|
+
const isUserManager = this.isUserManager(member);
|
|
1197
|
+
|
|
1175
1198
|
if (hasNotes && isUserManager && !(await this.canAccessMember(member, PermissionLevel.Full))) {
|
|
1176
1199
|
throw new SimpleError({
|
|
1177
1200
|
code: 'permission_denied',
|