Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions cron/reseed-auth0.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;');
Expand Down
11 changes: 9 additions & 2 deletions db/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
5 changes: 5 additions & 0 deletions library/lib/auth0.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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 = [];

Expand All @@ -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
Expand All @@ -850,6 +854,7 @@ function assignRolesToUser($userId, array $roleIds)
if (!HttpResponse::wasSuccessful($response, 204)) {
throw new Exception($response->getReasonPhrase(), $response->getStatusCode());
}
usleep(200000);
}

/**
Expand Down
Loading