Commit 8ac74e8a authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1640893: Save StudentID value when creating user via SAML auth



Allow the saving of Student ID along with currect things like
firstname, lastname etc when creating a user via SAML login

behatnotneeded

Change-Id: Ib6d8271878247573972c93d84c68698902e34a0f
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 23e00618
......@@ -60,6 +60,7 @@ $string['resetmetadata'] = 'Reset the certificates for Mahara\'s metadata. This
$string['samlfieldforemail'] = 'SSO field for email';
$string['samlfieldforfirstname'] = 'SSO field for first name';
$string['samlfieldforsurname'] = 'SSO field for surname';
$string['samlfieldforstudentid'] = 'SSO field for student ID';
$string['spentityid'] = "Service Provider entityId";
$string['title'] = 'SAML';
$string['updateuserinfoonlogin'] = 'Update user details on login';
......
......@@ -36,6 +36,7 @@ class AuthSaml extends Auth {
$this->config['firstnamefield' ] = '';
$this->config['surnamefield'] = '';
$this->config['emailfield'] = '';
$this->config['studentidfield'] = '';
$this->config['institutionattribute'] = '';
$this->config['institutionregex'] = 0;
$this->config['institutionvalue'] = '';
......@@ -90,6 +91,7 @@ class AuthSaml extends Auth {
$firstname = isset($attributes[$this->config['firstnamefield']][0]) ? $attributes[$this->config['firstnamefield']][0] : null;
$lastname = isset($attributes[$this->config['surnamefield']][0]) ? $attributes[$this->config['surnamefield']][0] : null;
$email = isset($attributes[$this->config['emailfield']][0]) ? $attributes[$this->config['emailfield']][0] : null;
$studentid = isset($attributes[$this->config['studentidfield']][0]) ? $attributes[$this->config['studentidfield']][0] : null;
$institutionname = $this->institution;
$create = false;
......@@ -183,6 +185,7 @@ class AuthSaml extends Auth {
$user->firstname = $firstname;
$user->lastname = $lastname;
$user->email = $email;
$user->studentid = $studentid;
// must have these values
if (empty($firstname) || empty($lastname) || empty($email)) {
......@@ -229,6 +232,11 @@ class AuthSaml extends Auth {
set_profile_field($user->id, 'email', $email);
$user->email = $email;
}
if (! empty($studentid)) {
set_profile_field($user->id, 'studentid', $studentid);
$user->studentid = $studentid;
}
$user->lastlastlogin = $user->lastlogin;
$user->lastlogin = time();
}
......@@ -280,6 +288,7 @@ class PluginAuthSaml extends PluginAuth {
'firstnamefield' => '',
'surnamefield' => '',
'emailfield' => '',
'studentidfield' => '',
'updateuserinfoonlogin' => 1,
'institution' => '',
'institutionattribute' => '',
......@@ -662,6 +671,12 @@ class PluginAuthSaml extends PluginAuth {
'defaultvalue' => self::$default_config['emailfield'],
'help' => true,
),
'studentidfield' => array(
'type' => 'text',
'title' => get_string('samlfieldforstudentid', 'auth.saml'),
'defaultvalue' => self::$default_config['studentidfield'],
'help' => true,
),
);
return array(
......@@ -806,6 +821,7 @@ class PluginAuthSaml extends PluginAuth {
'firstnamefield' => $values['firstnamefield'],
'surnamefield' => $values['surnamefield'],
'emailfield' => $values['emailfield'],
'studentidfield' => $values['studentidfield'],
'updateuserinfoonlogin' => $values['updateuserinfoonlogin'],
'institutionattribute' => $values['institutionattribute'],
'institutionvalue' => $values['institutionvalue'],
......
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