diff --git a/application/models/UserModel.php b/application/models/UserModel.php
index 8280ad3..ebcded7 100644
--- a/application/models/UserModel.php
+++ b/application/models/UserModel.php
@@ -67,20 +67,29 @@ public function insert()
public function update()
{
- $sql = "UPDATE $this->tableName SET timestamp=:timestamp, login=:login, pass=:pass, email=:email WHERE id = :id";
+ $sql = "UPDATE $this->tableName SET timestamp=:timestamp, login=:login, pass=:pass,salt = :salt,role = :role, email=:email WHERE id = :id";
$st = $this->pdo->prepare ( $sql );
$st->bindValue( ":timestamp", (new \DateTime('NOW'))->format('Y-m-d H:i:s'), \PDO::PARAM_STMT);
$st->bindValue( ":login", $this->login, \PDO::PARAM_STR );
+ if ($this->pass)
+ {
+ // Хеширование пароля
+ $this->salt = rand(0,1000000);
+ $st->bindValue( ":salt", $this->salt, \PDO::PARAM_STR );
+ $this->pass .= $this->salt;
+ $hashPass = password_hash($this->pass, PASSWORD_BCRYPT);
+ $st->bindValue( ":pass", $hashPass, \PDO::PARAM_STR );
+ }else {
+ $sqlPass = "SELECT pass, salt from $this->tableName where id = $this->id";
+ $password = $this->pdo->query($sqlPass);
+ $pass = $password->fetch();
+ $st->bindValue( ":pass", $pass['pass'], \PDO::PARAM_STR );
+ $st->bindValue( ":salt", $pass['salt'], \PDO::PARAM_STR );
+ }
+
- // Хеширование пароля
- $this->salt = rand(0,1000000);
- //$st->bindValue( ":salt", $this->salt, \PDO::PARAM_STR );
- //$this->pass .= $this->salt;
- //$hashPass = password_hash($this->pass, PASSWORD_BCRYPT);
- $st->bindValue( ":pass", $this->pass, \PDO::PARAM_STR );
-
- //$st->bindValue( ":role", $this->role, \PDO::PARAM_STR );
+ $st->bindValue( ":role", $this->role, \PDO::PARAM_STR );
$st->bindValue( ":email", $this->email, \PDO::PARAM_STR );
$st->bindValue( ":id", $this->id, \PDO::PARAM_INT );
$st->execute();
diff --git a/application/views/user/edit.php b/application/views/user/edit.php
index dccb87c..e3fc84d 100644
--- a/application/views/user/edit.php
+++ b/application/views/user/edit.php
@@ -23,7 +23,11 @@