|
|
@@ -109,7 +109,6 @@ class OtAuthenticationService extends AbstractAuthenticationService
|
|
|
*/
|
|
|
public function getUser()
|
|
|
{
|
|
|
-
|
|
|
// Does the user already have a session on the Opentalent API?
|
|
|
$username = $this->getAuthenticatedUsername();
|
|
|
|
|
|
@@ -293,7 +292,6 @@ class OtAuthenticationService extends AbstractAuthenticationService
|
|
|
*/
|
|
|
protected function createOrUpdateUser(): bool
|
|
|
{
|
|
|
-
|
|
|
// Get user's data from the API
|
|
|
$userApiData = $this->getUserData();
|
|
|
|
|
|
@@ -315,12 +313,36 @@ class OtAuthenticationService extends AbstractAuthenticationService
|
|
|
'name' => $userApiData['name'],
|
|
|
'first_name' => $userApiData['first_name'],
|
|
|
'description' => '[Warning: auto-generated record, do not modify] FE User',
|
|
|
- 'usergroup' => self::GROUP_FE_ALL_UID,
|
|
|
'deleted' => 0,
|
|
|
'tx_opentalent_opentalentId' => $userApiData['id'],
|
|
|
'tx_opentalent_generationDate' => date('Y/m/d H:i:s')
|
|
|
];
|
|
|
|
|
|
+ $groupsUid = [self::GROUP_FE_ALL_UID];
|
|
|
+ if ($userApiData['accesses']) {
|
|
|
+ foreach ($userApiData['accesses'] as $accessData) {
|
|
|
+ $organizationId = $accessData['organizationId'];
|
|
|
+
|
|
|
+ // get the fe_group for this organization
|
|
|
+ $groupUid = $connection->fetchOne(
|
|
|
+ "select g.uid
|
|
|
+ from typo3.fe_groups g
|
|
|
+ inner join (select uid, ot_website_uid from typo3.pages where is_siteroot) p
|
|
|
+ on g.pid = p.uid
|
|
|
+ inner join typo3.ot_websites w on p.ot_website_uid = w.uid
|
|
|
+ where w.organization_id=:organizationId;",
|
|
|
+ ['organizationId' => $organizationId]
|
|
|
+ );
|
|
|
+
|
|
|
+ if ($groupUid) {
|
|
|
+ $groupsUid[] = $groupUid;
|
|
|
+ } else {
|
|
|
+ $this->writeLogMessage("Warning: no fe_group found for organization " . $organizationId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $fe_row['usergroup'] = join(',', $groupsUid);
|
|
|
+
|
|
|
// TODO: log a warning if a user with the same opentalentId exists (the user might have changed of username)
|
|
|
$q = $connection->select(
|
|
|
['uid', 'tx_opentalent_opentalentId'],
|