Plugin: Azure Active Directory: Fix saving extra fields when auto-provisioning users (was preventing subsequent login) - refs BT#18507

pull/3844/head
Yannick Warnier 5 years ago
parent 27fad2a045
commit 918d95330b
  1. 2
      public/main/inc/lib/extra_field_value.lib.php
  2. 16
      public/main/inc/lib/usermanager.lib.php
  3. 4
      public/plugin/azure_active_directory/src/callback.php

@ -79,7 +79,7 @@ class ExtraFieldValue extends Model
* In order to save this function needs a item_id (user id, course id, etc)
* This function is used with $extraField->addElements().
*
* @param array $params array for the insertion into the *_field_values table
* @param array $params array for the insertion into the *_field_values table (each label must be prefixed by 'extra_')
* @param bool $onlySubmittedFields Only save parameters in the $param array
* @param bool $showQuery
* @param array $saveOnlyThisFields

@ -130,7 +130,7 @@ class UserManager
* @param string $expirationDate Account expiration date (optional, defaults to null)
* @param int $active Whether the account is enabled or disabled by default
* @param int $hr_dept_id The department of HR in which the user is registered (defaults to 0)
* @param array $extra Extra fields
* @param array $extra Extra fields (labels must be prefixed by "extra_")
* @param string $encrypt_method Used if password is given encrypted. Set to an empty string by default
* @param bool $send_mail
* @param bool $isAdmin
@ -377,8 +377,18 @@ class UserManager
if (is_array($extra) && count($extra) > 0) {
$extra['item_id'] = $userId;
$courseFieldValue = new ExtraFieldValue('user');
$courseFieldValue->saveFieldValues($extra);
$userFieldValue = new ExtraFieldValue('user');
/* Force saving of extra fields (otherwise, if the current
 user is not admin, fields not visible to the user - most
 of them - are just ignored) */
$userFieldValue->saveFieldValues(
$extra,
true,
null,
null,
null,
true
);
} else {
// Create notify settings by default
self::update_extra_field_value(

@ -94,8 +94,8 @@ try {
($me['accountEnabled'] ? 1 : 0),
null,
[
AzureActiveDirectory::EXTRA_FIELD_ORGANISATION_EMAIL => $me['mail'],
AzureActiveDirectory::EXTRA_FIELD_AZURE_ID => $me['mailNickname'],
'extra_'.AzureActiveDirectory::EXTRA_FIELD_ORGANISATION_EMAIL => $me['mail'],
'extra_'.AzureActiveDirectory::EXTRA_FIELD_AZURE_ID => $me['mailNickname'],
]
);
if (!$userId) {

Loading…
Cancel
Save