Commit b5678c25 authored by Francois Marier's avatar Francois Marier Committed by Gerrit Code Review
Browse files

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

parents 0ce047c6 549bd8eb
......@@ -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