$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');
}
$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)) {
$username = $s;
}
- $authplugin = get_auth_plugin('email');
+ $authplugin = get_auth_plugin($CFG->registerauth);
$confirmed = $authplugin->user_confirm($username, $usersecret);
if ($confirmed == AUTH_CONFIRM_ALREADY) {
}
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!');
}
// 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()) {
/// 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
$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");
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 = "";
}
} 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;
<div class="signuppanel">
<h2><?php print_string("firsttime") ?></h2>
<div class="subcontent">
-<?php switch ($authsequence[0]) {
- case "email":
- print_string("loginsteps", "", "signup.php");
-?>
+<?php if (is_enabled_auth('none')) { // instructions override the rest for security reasons
+ print_string("loginstepsnone");
+ } else if ($CFG->registerauth == 'email') {
+ if (!empty($CFG->auth_instructions)) {
+ echo format_text($CFG->auth_instructions);
+ } else {
+ print_string("loginsteps", "", "signup.php");
+ } ?>
<div class="signupform">
<form action="signup.php" method="get" id="signup">
<div><input type="submit" value="<?php print_string("startsignup") ?>" /></div>
</form>
</div>
-<?php break;
-
- case "none":
- print_string("loginstepsnone");
- break;
-
- default:
- echo format_text($CFG->auth_instructions);
- // TODO: if !function_exists(auth_user_login) then require_once /auth/$CFG->auth/lib.php
- // ..which implies that auth_user_login might have been floating
- // about in global namespace. grr
- $authplugin = get_auth_plugin($CFG->auth);
- if (!empty($CFG->auth_user_create) and method_exists($authplugin, 'user_create') ){
-?>
- <div class="signupform">
- <form action="signup.php" method="get" id="signup">
- <div><input type="submit" value="<?php print_string("startsignup") ?>" /></div>
- </form>
- </div>
-<?php }
- }
-?>
+<?php } else if (!empty($CFG->registerauth)) {
+ echo format_text($CFG->auth_instructions);
+ $authplugin = get_auth_plugin($CFG->registerauth);
+ if (method_exists($authplugin, 'user_create')) { ?>
+ <div class="signupform">
+ <form action="signup.php" method="get" id="signup">
+ <div><input type="submit" value="<?php print_string("startsignup") ?>" /></div>
+ </form>
+ </div>
+<?php }
+ } else {
+ echo format_text($CFG->auth_instructions);
+ } ?>
</div>
</div>
<?php } ?>
$sesskey = sesskey();
// if you are logged in then you shouldn't be here
-if (isloggedin() and !isguest()) {
+if (isloggedin() and !isguestuser()) {
redirect( $CFG->wwwroot.'/', get_string('loginalready'), 5);
}
require_once('../config.php');
require_once('signup_form.php');
- //HTTPS is potentially required in this page
- httpsrequired();
-
- $authplugin = get_auth_plugin($CFG->auth);
+ if (empty($CFG->registerauth)) {
+ error("Sorry, you may not use this page.");
+ }
+ $authplugin = get_auth_plugin($CFG->registerauth);
- if ($CFG->auth != 'email' and (empty($CFG->auth_user_create) or !(method_exists($authplugin, 'user_create'))) ) {
+ if (!method_exists($authplugin, 'user_create')) {
error("Sorry, you may not use this page.");
}
+ //HTTPS is potentially required in this page
+ httpsrequired();
+
$mform_signup = new login_signup_form_1();
if ($mform_signup->is_cancelled()) {
$user->firstaccess = time();
$user->mnethostid = $CFG->mnet_localhost_id;
$user->secret = random_string(15);
- $user->auth = $CFG->auth;
-
- if (!empty($CFG->auth_user_create) and method_exists($authplugin, 'user_create') ){
- if (! $authplugin->user_exists($user->username)) {
- if (! $authplugin->user_create($user, $plainpass)) {
- error("Could not add user to authentication module!");
- }
- } else {
- error("User already exists on authentication database.");
+ $user->auth = $CFG->registerauth;
+
+ if (! $authplugin->user_exists($user->username)) {
+ if (! $authplugin->user_create($user, $plainpass)) {
+ error("Could not add user to authentication module!");
}
+ } else {
+ error("User already exists on authentication database.");
}
- $authplugin = get_auth_plugin($CFG->auth);
+ $authplugin = get_auth_plugin($CFG->registerauth);
$signedup = $authplugin->user_signup($user, $notify=true);
exit;
}
global $CFG;
$errors = array();
- $authplugin = get_auth_plugin($CFG->auth);
+ $authplugin = get_auth_plugin($CFG->registerauth);
if (record_exists('user', 'username', $data['username'], 'mnethostid', $CFG->mnet_localhost_id)) {
$errors['username'] = get_string('usernameexists');
}
}
}
- if (isset($CFG->auth_user_create) and $CFG->auth_user_create==1 and method_exists($authplugin, 'user_exists')){
+ if (method_exists($authplugin, 'user_exists')){
if ($authplugin->user_exists($user->username)) {
$errors['username'] = get_string('usernameexists');
}