From 370ee131f2d518bc97bd79288968a347d9670291 Mon Sep 17 00:00:00 2001 From: Philipp Metzner Date: Fri, 11 Sep 2026 00:18:40 +0200 Subject: [PATCH 1/2] Update README --- README.md | 4 ++-- db/init.sql | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0fe9f17b..67e2247e 100644 --- a/README.md +++ b/README.md @@ -57,13 +57,13 @@ If you are interested in being part of this project, write us at [jointheteam@bo The database seed `db/init.sql` is generated in v2 and copied from there. -6. If you want to additionally want to connect the users from the seed to auth0 and populate the db table cms_usergroups_roles then open a browser and request `http://localhost:8100/cron/reseed-auth0.php` +6. If you want to connect new bases and organisations from the seed to Auth0 and populate the `cms_*` db tables, open a browser and request `http://localhost:8100/cron/reseed-auth0.php` (`init.sql` must contain the new bases) ### Accessing the app Once the docker containers are running the app is accessible at http://localhost:8100/ -After this you should be able to login to the app using the password Browser_tests and one of the following emails: +After this you should be able to login to the app using the password `Browser_tests` and one of the following emails: - some.admin@boxtribute.org (God User) diff --git a/db/init.sql b/db/init.sql index e377aa1d..5a72a155 100644 --- a/db/init.sql +++ b/db/init.sql @@ -254,7 +254,11 @@ INSERT INTO `camps` VALUES (1,0,0,'2019-01-01',1,25,25,NULL,NULL,'Lesvos',1,'0', (3,0,0,'2019-01-01',1,25,25,NULL,NULL,'Samos',2,'0','1.5','2019-10-14 13:30:00','2019-10-14 10:30:00','2019-10-14 17:00:00','0.5',4,0,0,0,'17:30','16:30',120,NULL,NULL,'Tokens','EUR','2019-01-06 22:18:10',60,9999,NULL,500,300,'150','130',1,'Household',0,0,1,1,0,0,0,0,0,0,0,NULL,NULL,NULL,NULL), (4,0,0,'2019-01-01',0,25,25,NULL,NULL,'Athens',2,'0','1','13:00','9:00','15:00','0.25',5,0,15,0,'17:30','16:30',120,NULL,NULL,'points','EUR','2019-11-05 09:13:11',9999,9999,NULL,99999,99999,'100','50',0,'Family ID',0,1,1,1,0,0,0,0,0,0,0,NULL,NULL,NULL,NULL), (100000000,1,0,'2019-01-01',1,25,25,'2019-09-05 13:48:34',1,'TestBase',100000000,'1','1','2019-09-05 13:00:00','2019-09-05 11:00:00','2019-09-05 17:00:00','0.5',3,0,15,0,'2019-09-05 17:30:00','2019-09-05 16:30:00',120,'2019-07-10 08:06:22',1,'Tokens','EUR','2019-01-01 00:00:00',9999,99999,NULL,99999,99999,'100','100',0,'Refugee ID',0,0,1,1,0,0,0,0,0,0,0,NULL,NULL,NULL,NULL), - (100000001,1,0,'2019-01-01',1,25,25,'2019-09-05 13:48:34',1,'DummyTestBaseWithBoxes',100000001,'1','1','2019-09-05 13:00:00','2019-09-05 11:00:00','2019-09-05 17:00:00','0.5',3,0,15,0,'2019-09-05 17:30:00','2019-09-05 16:30:00',120,'2019-07-10 08:06:22',1,'Tokens','EUR','2019-01-01 00:00:00',9999,30,NULL,99999,99999,'100','100',0,'Refugee ID',0,0,1,1,0,0,0,0,0,0,0,NULL,NULL,NULL,NULL); + (100000001,1,0,'2019-01-01',1,25,25,'2019-09-05 13:48:34',1,'DummyTestBaseWithBoxes',100000001,'1','1','2019-09-05 13:00:00','2019-09-05 11:00:00','2019-09-05 17:00:00','0.5',3,0,15,0,'2019-09-05 17:30:00','2019-09-05 16:30:00',120,'2019-07-10 08:06:22',1,'Tokens','EUR','2019-01-01 00:00:00',9999,30,NULL,99999,99999,'100','100',0,'Refugee ID',0,0,1,1,0,0,0,0,0,0,0,NULL,NULL,NULL,NULL), + (100000002,0,0,'2019-01-01',1,25,25,NULL,NULL,'Berlin',100000006,'1','1','13:00','11:00','17:00','0.5',6,0,15,0,'17:30','16:30',120,'2026-04-23 15:01:52',1,'Tokens','EUR','2019-01-01 00:00:00',9999,30,NULL,99999,99999,'100','100',0,'Container',0,0,1,1,0,0,0,0,0,0,0,NULL,NULL,NULL,NULL), + (100000003,0,0,'2019-01-01',1,25,25,NULL,NULL,'Rome',100000006,'1','1','2026-04-23 13:00:00','2026-04-23 11:00:00','2026-04-23 17:00:00','0.5',7,0,15,0,'2026-04-23 17:30:00','2026-04-23 16:30:00',120,'2026-04-23 15:05:11',1,'Tokens','EUR','2019-01-01 00:00:00',9999,30,NULL,99999,99999,'100','100',0,'Container',0,0,1,1,0,0,0,0,0,0,0,'','','',''), + (100000004,0,0,'2019-01-01',1,25,25,NULL,NULL,'Istanbul',100000007,'1','1','13:00','11:00','17:00','0.5',8,0,15,0,'17:30','16:30',120,'2026-04-27 09:19:00',1,'Tokens','EUR','2019-01-01 00:00:00',9999,30,NULL,99999,99999,'100','100',0,'Container',0,0,1,1,0,0,0,0,0,0,0,NULL,NULL,NULL,NULL), + (100000005,0,0,'2019-01-01',1,25,25,NULL,NULL,'London',100000008,'1','1','13:00','11:00','17:00','0.5',9,0,15,0,'17:30','16:30',120,'2026-04-27 09:21:08',1,'Tokens','EUR','2019-01-01 00:00:00',9999,30,NULL,99999,99999,'100','100',0,'Container',0,0,1,1,0,0,0,0,0,0,0,NULL,NULL,NULL,NULL); /*!40000 ALTER TABLE `camps` ENABLE KEYS */; UNLOCK TABLES; @@ -1332,7 +1336,10 @@ INSERT INTO `organisations` VALUES (1,'BoxAid',NULL,NULL,NULL,NULL,NULL), (3,'NoCampsOrg',NULL,NULL,NULL,NULL,NULL), (4,'TheDeletedOrg',NULL,NULL,'2023-12-31 11:22:33',NULL,NULL), (100000000,'TestOrganisation','2019-07-10 08:05:56',1,NULL,NULL,NULL), - (100000001,'DummyTestOrgWithBoxes','2019-09-29 08:05:56',1,NULL,NULL,NULL); + (100000001,'DummyTestOrgWithBoxes','2019-09-29 08:05:56',1,NULL,NULL,NULL), + (100000006,'BoxHelpers','2026-04-23 15:01:52',1,NULL,NULL,NULL), + (100000007,'WeHaveBoxes','2026-04-27 09:19:00',1,NULL,NULL,NULL), + (100000008,'DistributeFairly','2026-04-27 09:21:08',1,NULL,NULL,NULL); /*!40000 ALTER TABLE `organisations` ENABLE KEYS */; UNLOCK TABLES; From 59db39716dfd3c5e62d413b18776264a02a9bd48 Mon Sep 17 00:00:00 2001 From: Philipp Metzner Date: Fri, 11 Sep 2026 00:19:32 +0200 Subject: [PATCH 2/2] Use usleep to avoid hitting Auth0 rate limits --- cron/reseed-auth0.php | 1 + library/lib/auth0.php | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/cron/reseed-auth0.php b/cron/reseed-auth0.php index 4eb8bfe8..f7319840 100644 --- a/cron/reseed-auth0.php +++ b/cron/reseed-auth0.php @@ -35,6 +35,7 @@ while ($row = db_fetch($result)) { $role = getRolesByName($row['auth0_role_name']); db_query('UPDATE cms_usergroups_roles SET auth0_role_id = :id WHERE auth0_role_name = :rolename', ['id' => $role['id'], 'rolename' => $row['auth0_role_name']]); + usleep(200000); } $db_users = db_query('SELECT id FROM cms_users;'); diff --git a/library/lib/auth0.php b/library/lib/auth0.php index 4fcc2665..0de887c1 100644 --- a/library/lib/auth0.php +++ b/library/lib/auth0.php @@ -136,12 +136,14 @@ function updateAuth0UserFromDb($userId, $setPwd = false) } $response = $mgmtAPI->users()->update($auth0UserId, $auth0UserData); + usleep(200000); // user doesn't exist, so try creating it instead if (404 === $response->getStatusCode()) { $auth0UserData['user_id'] = preg_replace('/auth0\|/', '', $auth0UserId); $auth0UserData['password'] = generateSecureRandomString(); // user will need to reset password anyway $response = $mgmtAPI->users()->create($settings['auth0_db_connection_id'], $auth0UserData); + usleep(200000); // the status code will be 201 if the user created successfully if (201 !== $response->getStatusCode()) { @@ -822,6 +824,7 @@ function assignRolesToUser($userId, array $roleIds) $mgmtAPI = getAuth0Management($settings); // getting current roles for thr users $response = $mgmtAPI->users()->getRoles($userId); + usleep(200000); $removeRolesIds = []; @@ -842,6 +845,7 @@ function assignRolesToUser($userId, array $roleIds) if (!HttpResponse::wasSuccessful($response, 204)) { throw new Exception($response->getReasonPhrase(), $response->getStatusCode()); } + usleep(200000); } // assigning the new roles to the users @@ -850,6 +854,7 @@ function assignRolesToUser($userId, array $roleIds) if (!HttpResponse::wasSuccessful($response, 204)) { throw new Exception($response->getReasonPhrase(), $response->getStatusCode()); } + usleep(200000); } /**