mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-58220 oauth2: Use the same list of user fields
Authentication has a hard coded list of valid internal user fields - but they are in a class variable. We need them in oauth user_field_mapping so we need to move them to a central place and call them from oauth2 and auth.
This commit is contained in:
parent
68ecf7635b
commit
d9fbe3146c
@ -102,26 +102,7 @@ class auth_plugin_base {
|
||||
* The fields we can lock and update from/to external authentication backends
|
||||
* @var array
|
||||
*/
|
||||
var $userfields = array(
|
||||
'firstname',
|
||||
'lastname',
|
||||
'email',
|
||||
'city',
|
||||
'country',
|
||||
'lang',
|
||||
'description',
|
||||
'url',
|
||||
'idnumber',
|
||||
'institution',
|
||||
'department',
|
||||
'phone1',
|
||||
'phone2',
|
||||
'address',
|
||||
'firstnamephonetic',
|
||||
'lastnamephonetic',
|
||||
'middlename',
|
||||
'alternatename'
|
||||
);
|
||||
var $userfields = \core_user::AUTHSYNCFIELDS;
|
||||
|
||||
/**
|
||||
* Moodle custom fields to sync with.
|
||||
|
@ -37,21 +37,14 @@ class user_field_mapping extends persistent {
|
||||
|
||||
const TABLE = 'oauth2_user_field_mapping';
|
||||
|
||||
/** @var array $userfields - List of standard Moodle userfields. */
|
||||
private static $userfields = [
|
||||
'firstname',
|
||||
'middlename',
|
||||
'lastname',
|
||||
'email',
|
||||
'username',
|
||||
'idnumber',
|
||||
'url',
|
||||
'alternatename',
|
||||
'picture',
|
||||
'address',
|
||||
'phone',
|
||||
'lang'
|
||||
];
|
||||
/**
|
||||
* Return the list of valid internal user fields.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private static function get_user_fields() {
|
||||
return array_merge(\core_user::AUTHSYNCFIELDS, ['picture']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the definition of the properties of this model.
|
||||
@ -68,7 +61,7 @@ class user_field_mapping extends persistent {
|
||||
),
|
||||
'internalfield' => array(
|
||||
'type' => PARAM_ALPHANUMEXT,
|
||||
'choices' => self::$userfields,
|
||||
'choices' => self::get_user_fields()
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -79,6 +72,6 @@ class user_field_mapping extends persistent {
|
||||
* @return array
|
||||
*/
|
||||
public function get_internalfield_list() {
|
||||
return array_combine(self::$userfields, self::$userfields);
|
||||
return array_combine(self::get_user_fields(), self::get_user_fields());
|
||||
}
|
||||
}
|
||||
|
@ -58,6 +58,30 @@ class core_user {
|
||||
*/
|
||||
const MAILDISPLAY_COURSE_MEMBERS_ONLY = 2;
|
||||
|
||||
/**
|
||||
* List of fields that can be synched/locked during authentication.
|
||||
*/
|
||||
const AUTHSYNCFIELDS = [
|
||||
'firstname',
|
||||
'lastname',
|
||||
'email',
|
||||
'city',
|
||||
'country',
|
||||
'lang',
|
||||
'description',
|
||||
'url',
|
||||
'idnumber',
|
||||
'institution',
|
||||
'department',
|
||||
'phone1',
|
||||
'phone2',
|
||||
'address',
|
||||
'firstnamephonetic',
|
||||
'lastnamephonetic',
|
||||
'middlename',
|
||||
'alternatename'
|
||||
];
|
||||
|
||||
/** @var stdClass keep record of noreply user */
|
||||
public static $noreplyuser = false;
|
||||
|
||||
@ -887,4 +911,5 @@ class core_user {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user