MDL-16919 - Allow username to contain alphanumeric lowercase characters, underscore (_), hyphen (-), period (.) or at symbol (@)
This commit is contained in:
@@ -63,7 +63,7 @@ if ($id == -1) {
|
||||
require_capability('moodle/user:create', $systemcontext);
|
||||
$user = new object();
|
||||
$user->id = -1;
|
||||
$user->auth = 'manual';
|
||||
$user->auth = 'manual';
|
||||
$user->confirmed = 1;
|
||||
$user->deleted = 0;
|
||||
} else {
|
||||
@@ -135,17 +135,17 @@ if ($usernew = $userform->get_data()) {
|
||||
} else {
|
||||
$authplugin = get_auth_plugin($usernew->auth);
|
||||
}
|
||||
|
||||
$usernew->username = trim($usernew->username);
|
||||
$usernew->timemodified = time();
|
||||
|
||||
$usernew->username = clean_param($usernew->username, PARAM_USERNAME);
|
||||
$usernew->timemodified = time();
|
||||
|
||||
if ($usernew->id == -1) {
|
||||
//TODO check out if it makes sense to create account with this auth plugin and what to do with the password
|
||||
unset($usernew->id);
|
||||
$usernew = file_postupdate_standard_editor($usernew, 'description', $editoroptions, null, 'user_profile', null);
|
||||
$usernew->mnethostid = $CFG->mnet_localhost_id; // always local user
|
||||
$usernew->confirmed = 1;
|
||||
$usernew->password = hash_internal_user_password($usernew->newpassword);
|
||||
$usernew->confirmed = 1;
|
||||
$usernew->password = hash_internal_user_password($usernew->newpassword);
|
||||
$usernew->id = $DB->insert_record('user', $usernew);
|
||||
$usercreated = true;
|
||||
|
||||
@@ -223,7 +223,7 @@ if ($usernew = $userform->get_data()) {
|
||||
redirect("$CFG->wwwroot/user/view.php?id=$USER->id&course=$course->id");
|
||||
}
|
||||
} else {
|
||||
session_gc(); // remove stale sessions
|
||||
session_gc(); // remove stale sessions
|
||||
redirect("$CFG->wwwroot/$CFG->admin/user.php");
|
||||
}
|
||||
//never reached
|
||||
|
||||
Reference in New Issue
Block a user