[eluser]Go-Trex[/eluser]
Hi,
Set the following settings in config/auth.php
Code:
$config['use_username'] = FALSE;
$config['login_by_username'] = FALSE;
$config['login_by_email'] = TRUE;
When a visitor registers at your site they do not need to fill in a username and when they log in they can only log in with a valid email address and password combination.
When you want to save the email address as a username overwrite the following function in libraries/Tank_auth.php
Code:
function create_user($username, $email, $password, $email_activation)
{
if (!$this->ci->users->is_email_available($email)) {
$this->error = array('email' => 'auth_email_in_use');
} else {
// Hash password using phpass
$hasher = new PasswordHash(
$this->ci->config->item('phpass_hash_strength', 'tank_auth'),
$this->ci->config->item('phpass_hash_portable', 'tank_auth'));
$hashed_password = $hasher->HashPassword($password);
$data = array(
'username' => $email,
'password' => $hashed_password,
'email' => $email,
'last_ip' => $this->ci->input->ip_address(),
);
if ($email_activation) {
$data['new_email_key'] = md5(rand().microtime());
}
if (!is_null($res = $this->ci->users->create_user($data, !$email_activation))) {
$data['user_id'] = $res['user_id'];
$data['password'] = $password;
unset($data['last_ip']);
return $data;
}
}
return NULL;
}