From 798cd5d80385705503c81be269c008e163fcbdba Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Thu, 10 Mar 2016 18:36:46 -0500 Subject: Add function User::setPassword() This user function will update the salt and key for a user object to change its password. --- app/class/user.class.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/class/user.class.php b/app/class/user.class.php index 4f1bbfe..75b769a 100644 --- a/app/class/user.class.php +++ b/app/class/user.class.php @@ -99,8 +99,7 @@ class User extends Object $this->perms = 0; $this->name = $username; $this->type = "user"; - $this->salt = $this->getBlob(); - $this->key = $this->getKey($password, $this->salt); + $this->setPassword($password); $this->emailConf = 0; $this->emailConfKey = $this->getBlob(); @@ -121,6 +120,15 @@ class User extends Object return $key == $this->key; } + /* + * Overwrite the salt and key for this user, given a new plaintext password + */ + function setPassword($password) + { + $this->salt = $this->getBlob(); + $this->key = $this->getKey($password, $this->salt); + } + /* * If a user has an alias set, display it instead of their username */ -- cgit v1.2.3