diff --git a/admin/controllers/edit-user.php b/admin/controllers/edit-user.php index f84fbff2..f0705ba4 100644 --- a/admin/controllers/edit-user.php +++ b/admin/controllers/edit-user.php @@ -11,7 +11,7 @@ function editUser($args) if(isset($args['password'])) { if( ($args['password']===$args['confirm-password']) && !Text::isEmpty($args['password']) ) { - return $dbUsers->set($args); + return $dbUsers->setPassword($args); } else { Alert::set('Passwords are differents.'); diff --git a/kernel/dbusers.class.php b/kernel/dbusers.class.php index e052069b..5fa2310b 100644 --- a/kernel/dbusers.class.php +++ b/kernel/dbusers.class.php @@ -42,6 +42,17 @@ class dbUsers extends dbJSON return $this->db; } + public function setPassword($args) + { + $salt = Text::randomText(SALT_LENGTH); + $hash = sha1($args['password'].$salt); + + $args['salt'] = $salt; + $args['password'] = $hash; + + return $this->set($args); + } + public function set($args) { $dataForDb = array();