Commit 884b9f71 authored by Kevin Rickis's avatar Kevin Rickis Committed by Robert Lyon

Bug 1486699: get_new_username() truncating username badly for SAML

Ends up with username in auth_remote_user being different to the
username in usr table.

behatnotneeded

Change-Id: If6a5a18360ef82da2e3a709899e7d4d1624e8fab
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
(cherry picked from commit dc3b3292)
parent 69c32f56
......@@ -183,7 +183,7 @@ class AuthSaml extends Auth {
$user->authinstance = empty($this->config['parent']) ? $this->instanceid : $this->parent;
db_begin();
$user->username = get_new_username($remoteuser);
$user->username = get_new_username($remoteuser, 40);
$user->id = create_user($user, array(), $institutionname, $this, $remoteuser);
......
......@@ -1683,9 +1683,9 @@ function load_user_institutions($userid) {
* Return a username which isn't taken and which is similar to a desired username
*
* @param string $desired
* @param string $maxlen Maximum length of desired username
*/
function get_new_username($desired) {
$maxlen = 30;
function get_new_username($desired, $maxlen=30) {
if (function_exists('mb_strtolower')) {
$desired = mb_strtolower(mb_substr($desired, 0, $maxlen, 'UTF-8'), 'UTF-8');
}
......
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