diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2016-12-02 07:08:15 +0300 |
---|---|---|
committer | Matthieu Aubry <mattab@users.noreply.github.com> | 2016-12-02 07:08:15 +0300 |
commit | a9038318a94cc32f0f15add5272322ff6afe71f5 (patch) | |
tree | 9bcd2bf82fe8087e819ce679d07c678b92660ec0 /plugins/UsersManager/Model.php | |
parent | c10a289bf1e6dc11347b3d0f7235ffd9fa9aaaad (diff) |
Password hashing (#10926)
Diffstat (limited to 'plugins/UsersManager/Model.php')
-rw-r--r-- | plugins/UsersManager/Model.php | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/plugins/UsersManager/Model.php b/plugins/UsersManager/Model.php index db0285eab6..a45aebaf2d 100644 --- a/plugins/UsersManager/Model.php +++ b/plugins/UsersManager/Model.php @@ -8,6 +8,7 @@ */ namespace Piwik\Plugins\UsersManager; +use Piwik\Auth\Password; use Piwik\Common; use Piwik\Db; use Piwik\Piwik; @@ -29,8 +30,14 @@ class Model private static $rawPrefix = 'user'; private $table; + /** + * @var Password + */ + private $passwordHelper; + public function __construct() { + $this->passwordHelper = new Password(); $this->table = Common::prefixTable(self::$rawPrefix); } @@ -183,11 +190,11 @@ class Model return $db->fetchRow('SELECT * FROM ' . $this->table . ' WHERE token_auth = ?', $tokenAuth); } - public function addUser($userLogin, $passwordTransformed, $email, $alias, $tokenAuth, $dateRegistered) + public function addUser($userLogin, $hashedPassword, $email, $alias, $tokenAuth, $dateRegistered) { $user = array( 'login' => $userLogin, - 'password' => $passwordTransformed, + 'password' => $hashedPassword, 'alias' => $alias, 'email' => $email, 'token_auth' => $tokenAuth, @@ -238,13 +245,20 @@ class Model return $users; } - public function updateUser($userLogin, $password, $email, $alias, $tokenAuth) + public function updateUser($userLogin, $hashedPassword, $email, $alias, $tokenAuth) + { + $this->updateUserFields($userLogin, array( + 'password' => $hashedPassword, + 'alias' => $alias, + 'email' => $email, + 'token_auth' => $tokenAuth + )); + } + + public function updateUserTokenAuth($userLogin, $tokenAuth) { $this->updateUserFields($userLogin, array( - 'password' => $password, - 'alias' => $alias, - 'email' => $email, - 'token_auth' => $tokenAuth + 'token_auth' => $tokenAuth )); } |