Skip to content

Commit

Permalink
Merge branch 'w28_MDL-34101_m24_newaccountprev' of git://github.com/s…
Browse files Browse the repository at this point in the history
…kodak/moodle
  • Loading branch information
Sam Hemelryk committed Jul 10, 2012
2 parents 4b9e493 + 8956a32 commit 8f19a94
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions lib/moodlelib.php
Expand Up @@ -4045,12 +4045,19 @@ function authenticate_user_login($username, $password) {
$auths = array($auth);

} else {
// check if there's a deleted record (cheaply)
if ($DB->get_field('user', 'id', array('username'=>$username, 'deleted'=>1))) {
// Check if there's a deleted record (cheaply), this should not happen because we mangle usernames in delete_user().
if ($DB->get_field('user', 'id', array('username'=>$username, 'mnethostid'=>$CFG->mnet_localhost_id, 'deleted'=>1))) {
error_log('[client '.getremoteaddr()."] $CFG->wwwroot Deleted Login: $username ".$_SERVER['HTTP_USER_AGENT']);
return false;
}

// Do not try to authenticate non-existent accounts when user creation is not disabled.
if (!empty($CFG->authpreventaccountcreation)) {
add_to_log(SITEID, 'login', 'error', 'index.php', $username);
error_log('[client '.getremoteaddr()."] $CFG->wwwroot Unknown user, can not create new accounts: $username ".$_SERVER['HTTP_USER_AGENT']);
return false;
}

// User does not exist
$auths = $authsenabled;
$user = new stdClass();
Expand Down Expand Up @@ -4082,12 +4089,8 @@ function authenticate_user_login($username, $password) {
$user = update_user_record($username);
}
} else {
// if user not found and user creation is not disabled, create it
if (empty($CFG->authpreventaccountcreation)) {
$user = create_user_record($username, $password, $auth);
} else {
continue;
}
// Create account, we verified above that user creation is allowed.
$user = create_user_record($username, $password, $auth);
}

$authplugin->sync_roles($user);
Expand Down

0 comments on commit 8f19a94

Please sign in to comment.