@stamhoofd/backend 2.38.0 → 2.39.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stamhoofd/backend",
3
- "version": "2.38.0",
3
+ "version": "2.39.0",
4
4
  "main": "./dist/index.js",
5
5
  "exports": {
6
6
  ".": {
@@ -36,14 +36,14 @@
36
36
  "@simonbackx/simple-encoding": "2.15.1",
37
37
  "@simonbackx/simple-endpoints": "1.14.0",
38
38
  "@simonbackx/simple-logging": "^1.0.1",
39
- "@stamhoofd/backend-i18n": "2.38.0",
40
- "@stamhoofd/backend-middleware": "2.38.0",
41
- "@stamhoofd/email": "2.38.0",
42
- "@stamhoofd/models": "2.38.0",
43
- "@stamhoofd/queues": "2.38.0",
44
- "@stamhoofd/sql": "2.38.0",
45
- "@stamhoofd/structures": "2.38.0",
46
- "@stamhoofd/utility": "2.38.0",
39
+ "@stamhoofd/backend-i18n": "2.39.0",
40
+ "@stamhoofd/backend-middleware": "2.39.0",
41
+ "@stamhoofd/email": "2.39.0",
42
+ "@stamhoofd/models": "2.39.0",
43
+ "@stamhoofd/queues": "2.39.0",
44
+ "@stamhoofd/sql": "2.39.0",
45
+ "@stamhoofd/structures": "2.39.0",
46
+ "@stamhoofd/utility": "2.39.0",
47
47
  "archiver": "^7.0.1",
48
48
  "aws-sdk": "^2.885.0",
49
49
  "axios": "1.6.8",
@@ -60,5 +60,5 @@
60
60
  "postmark": "^4.0.5",
61
61
  "stripe": "^16.6.0"
62
62
  },
63
- "gitHead": "4af6773c9729d690145d60993542452989d6219d"
63
+ "gitHead": "cd1e314ceb591109b8b38dbf1bfbeda472516e28"
64
64
  }
@@ -952,12 +952,9 @@ export class AdminPermissionChecker {
952
952
  const isUserManager = this.isUserManager(member)
953
953
  if (isUserManager) {
954
954
  // For the user manager, we don't delete data, because when registering a new member, it doesn't have any organizations yet...
955
-
956
- // Notes are not visible for the member.
957
- data.details.notes = null;
958
-
959
955
  if (!(await this.canAccessMember(member, PermissionLevel.Full))) {
960
956
  data.details.securityCode = null;
957
+ data.details.notes = null;
961
958
  }
962
959
 
963
960
  return data;
@@ -1065,7 +1062,7 @@ export class AdminPermissionChecker {
1065
1062
  }
1066
1063
  }
1067
1064
 
1068
- if (hasNotes && isUserManager) {
1065
+ if (hasNotes && isUserManager && !(await this.canAccessMember(member, PermissionLevel.Full))) {
1069
1066
  throw new SimpleError({
1070
1067
  code: 'permission_denied',
1071
1068
  message: 'Cannot edit notes',
@@ -41,7 +41,8 @@ export class MemberUserSyncerStatic {
41
41
 
42
42
  // Link parents and unverified emails
43
43
  // Now we add the responsibility permissions to the parent if there are no userEmails
44
- await this.linkUser(email, member, userEmails.length > 0, userEmails.length > 0)
44
+ const asParent = userEmails.length > 0 || !member.details.unverifiedEmails.includes(email) || member.details.defaultAge < 16;
45
+ await this.linkUser(email, member, asParent, true)
45
46
  }
46
47
 
47
48
  if (unlinkUsers && !member.details.parentsHaveAccess) {
@@ -63,7 +64,7 @@ export class MemberUserSyncerStatic {
63
64
  await this.unlinkUser(user, member)
64
65
  } else {
65
66
  // Make sure only linked as a parent, not as user self
66
- // This makes sure we don't inherit permissions and aren't counted as 'begin' the member
67
+ // This makes sure we don't inherit permissions and aren't counted as 'being' the member
67
68
  await this.linkUser(user.email, member, true)
68
69
  }
69
70
  }
@@ -0,0 +1,51 @@
1
+ import { Migration } from '@simonbackx/simple-database';
2
+ import { Registration } from '@stamhoofd/models';
3
+
4
+ export default new Migration(async () => {
5
+ if (STAMHOOFD.environment == "test") {
6
+ console.log("skipped in tests")
7
+ return;
8
+ }
9
+
10
+ if(STAMHOOFD.userMode !== "platform") {
11
+ console.log("skipped seed schedule-stock-updates because usermode not platform")
12
+ return;
13
+ }
14
+
15
+ process.stdout.write('\n');
16
+ let c = 0;
17
+ let id: string = '';
18
+
19
+ while(true) {
20
+ const rawRegistrations = await Registration.where({
21
+ id: {
22
+ value: id,
23
+ sign: '>'
24
+ }
25
+ }, {limit: 100, sort: ['id']});
26
+
27
+ const registrations = await Registration.getByIDs(...rawRegistrations.map(g => g.id));
28
+
29
+ for (const registration of registrations) {
30
+ registration.scheduleStockUpdate();
31
+
32
+ c++;
33
+
34
+ if (c%1000 === 0) {
35
+ process.stdout.write('.');
36
+ }
37
+ if (c%10000 === 0) {
38
+ process.stdout.write('\n');
39
+ }
40
+ }
41
+
42
+ if (registrations.length === 0) {
43
+ break;
44
+ }
45
+
46
+ id = registrations[registrations.length - 1].id;
47
+ }
48
+
49
+ // Do something here
50
+ return Promise.resolve()
51
+ })