Bug fix for #606

This commit is contained in:
floppy0 2018-01-15 17:13:46 +01:00
parent b740e660b8
commit bcc986fa11
1 changed files with 10 additions and 9 deletions

View File

@ -87,6 +87,13 @@ class dbUsers extends dbJSON
}
}
// Set a new password
if (!empty($args['password'])) {
$user['salt'] = $this->generateSalt();
$user['password'] = $this->generatePasswordHash($args['password'], $user['salt']);
$user['tokenAuth'] = $this->generateAuthToken();
}
// Save the database
$this->db[$args['username']] = $user;
return $this->save();
@ -142,14 +149,8 @@ class dbUsers extends dbJSON
public function setPassword($username, $password)
{
$salt = $this->generateSalt();
$hash = $this->generatePasswordHash($password, $salt);
$tokenAuth = $this->generateAuthToken();
$args['username'] = $username;
$args['salt'] = $salt;
$args['password'] = $hash;
$args['tokenAuth'] = $tokenAuth;
return $this->set($args);
}