Commit 549bd8eb authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Set new profile fields when creating users from LDAP (bug #906996)



When users are automatically created from an LDAP server, the student
id & display name fields are set in the user table, but not updated as
profile fields in the artefact table, so they're not displayed in the
Edit profile page.

Passing the student id & display name from the auth plugin's
get_user_info function into create_user will ensure they're set as
profile fields as well.

Change-Id: I3ae769394d2f65577f26759309affdfd59070302
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent 10b13ad2
......@@ -1331,17 +1331,22 @@ function login_submit(Pieform $form, $values) {
// The user will be asked to populate this when they log in.
$USER->email = null;
}
if (isset($userdata->studentid)) {
$USER->studentid = sanitize_studentid($userdata->studentid);
}
if (isset($userdata->preferredname)) {
$USER->preferredname = sanitize_preferredname($userdata->preferredname);
$profilefields = array();
foreach (array('studentid', 'preferredname') as $pf) {
if (isset($userdata->$pf)) {
$sanitize = 'sanitize_' . $pf;
if (($USER->$pf = $sanitize($userdata->$pf)) !== '') {
$profilefields[$pf] = $USER->$pf;
}
}
}
try {
// If this authinstance is a parent auth for some xmlrpc authinstance, pass it along to create_user
// so that this username also gets recorded as the username for sso from the remote sites.
$remoteauth = count_records('auth_instance_config', 'field', 'parent', 'value', $authinstance->id) ? $authinstance : null;
create_user($USER, array(), $institution, $remoteauth);
create_user($USER, $profilefields, $institution, $remoteauth);
$USER->reanimate($USER->id, $authinstance->id);
}
catch (Exception $e) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment