diff --git a/login/change_password.php b/login/change_password.php index f9e55c4e120..08896e4b0d6 100644 --- a/login/change_password.php +++ b/login/change_password.php @@ -58,8 +58,6 @@ $userauth = get_auth_plugin($user->auth); if ($userauth->can_change_password()){ if ($userauth->user_update_password($user, $data->newpassword1)) { - // hash the $user->password field (without local db update) - update_internal_user_password($user, $data->newpassword1, false); } else { error('Could not set the new password'); } diff --git a/login/confirm.php b/login/confirm.php index 51c4b6f3d74..bef52d37f42 100644 --- a/login/confirm.php +++ b/login/confirm.php @@ -7,6 +7,15 @@ $p = optional_param('p', '', PARAM_ALPHANUM); // Old parameter: secret $s = optional_param('s', '', PARAM_CLEAN); // Old parameter: username + if (empty($CFG->registerauth)) { + error("Sorry, you may not use this page."); + } + $authplugin = get_auth_plugin($CFG->registerauth); + + if (!method_exists($authplugin, 'user_create')) { + error("Sorry, you may not use this page."); + } + if (!empty($data) || (!empty($p) && !empty($s))) { if (!empty($data)) { @@ -18,7 +27,7 @@ $username = $s; } - $authplugin = get_auth_plugin('email'); + $authplugin = get_auth_plugin($CFG->registerauth); $confirmed = $authplugin->user_confirm($username, $usersecret); if ($confirmed == AUTH_CONFIRM_ALREADY) { @@ -32,8 +41,8 @@ } if ($confirmed == AUTH_CONFIRM_OK) { // Activate new user if necessary - $authplugin = get_auth_plugin($CFG->auth); - if (isset($CFG->auth_user_create) and $CFG->auth_user_create == 1 and method_exists($authplugin, 'user_activate') ) { + $authplugin = get_auth_plugin($CFG->registerauth); + if (method_exists($authplugin, 'user_activate')) { if (!$authplugin->user_activate($username)) { error('Could not activate this user!'); } diff --git a/login/forgot_password.php b/login/forgot_password.php index f029c730369..520b4137812 100644 --- a/login/forgot_password.php +++ b/login/forgot_password.php @@ -42,14 +42,10 @@ $page = ''; // page to display // if you are logged in then you shouldn't be here! -if (isloggedin() && !isguest()) { +if (isloggedin() && !isguestuser()) { redirect($CFG->wwwroot.'/index.php', $strloginalready, 5); } -// instantiate default auth -$auth = $CFG->auth; // the 'default' authentication method -$defaultauth = get_auth_plugin($auth); - $mform = new login_forgot_password_form(); if ($mform->is_cancelled()) { diff --git a/login/index.php b/login/index.php index 579d86b7422..52bb75a03ef 100644 --- a/login/index.php +++ b/login/index.php @@ -41,17 +41,21 @@ /// Load alternative login screens if necessary -// check if auth config broken (old config --> multi config) -if (empty($CFG->auth_plugins_enabled) and ! empty($CFG->auth)) { - set_config('auth_plugins_enabled', $CFG->auth); -} -$authsequence = explode(',', $CFG->auth_plugins_enabled); // auths, in sequence +$authsequence = explode(',', $CFG->auth); // auths, in sequence // Load alternative login screens if necessary if ($authsequence[0] == 'cas' and !empty($CFG->cas_enabled)) { require($CFG->dirroot.'/auth/cas/login.php'); } +if (!isset($CFG->registerauth)) { + set_config('registerauth', ''); +} + +if (!isset($CFG->auth_instructions)) { + set_config('auth_instructions', ''); +} + // See http://moodle.org/mod/forum/discuss.php?d=39918#187611 // if ($CFG->auth == 'shibboleth') { // if (!empty($SESSION->shibboleth_checked) ) { // Just come from there @@ -114,7 +118,7 @@ if ($authsequence[0] == 'cas' and !empty($CFG->cas_enabled)) { $frm->username = trim(moodle_strtolower($frm->username)); - if ($CFG->auth == 'none' && empty($CFG->extendedusernamechars)) { + if (is_enabled_auth('none') && empty($CFG->extendedusernamechars)) { $string = eregi_replace("[^(-\.[:alnum:])]", "", $frm->username); if (strcmp($frm->username, $string)) { $errormsg = get_string('username').': '.get_string("alphanumerical"); @@ -264,7 +268,7 @@ if ($authsequence[0] == 'cas' and !empty($CFG->cas_enabled)) { set_moodle_cookie('nobody'); // To help search for cookies } -if (empty($frm->username) && $authsequence[0] != 'shibboleth') { // See bug 5184 + if (empty($frm->username) && $authsequence[0] != 'shibboleth') { // See bug 5184 $frm->username = get_moodle_cookie() === 'nobody' ? '' : get_moodle_cookie(); $frm->password = ""; } @@ -274,11 +278,8 @@ if (empty($frm->username) && $authsequence[0] != 'shibboleth') { // See bug 518 } else { $focus = "username"; } - - if (isset($CFG->auth_instructions)) { - $CFG->auth_instructions = trim($CFG->auth_instructions); - } -if ($authsequence[0] == "email" or $authsequence[0] == "none" or !empty($CFG->auth_instructions)) { + + if (!empty($CFG->registerauth) or is_enabled_auth('none') or !empty($CFG->auth_instructions)) { $show_instructions = true; } else { $show_instructions = false; diff --git a/login/index_form.html b/login/index_form.html index ae4e10458b2..0bcecc98549 100644 --- a/login/index_form.html +++ b/login/index_form.html @@ -76,37 +76,32 @@ if ($show_instructions) {