Updated adduser to check for existing user and use password hashing

This commit is contained in:
laf
2014-10-06 18:39:48 +01:00
parent c02e0c93ad
commit 7f95922160

View File

@ -49,7 +49,13 @@ function auth_usermanagement()
function adduser($username, $password, $level, $email = "", $realname = "", $can_modify_passwd = '1')
{
return dbInsert(array('username' => $username, 'password' => $password, 'level' => $level, 'email' => $email, 'realname' => $realname), 'users');
if (!user_exists($username)) {
$hasher = new PasswordHash(8, FALSE);
$encrypted = $hasher->HashPassword($password);
return dbInsert(array('username' => $username, 'password' => $encrypted, 'level' => $level, 'email' => $email, 'realname' => $realname), 'users');
} else {
return FALSE;
}
}
function user_exists($username)