v0.1.5bc Try to fix user update with empty text box

This commit is contained in:
Victor 2021-06-09 12:47:36 +02:00
parent 7c5345ac8a
commit 59f91682a7
1 changed files with 10 additions and 3 deletions

View File

@ -6,9 +6,16 @@ use Backend\Model\User;
if(isset($_POST['id'])){
$user = User::query()->find($_POST['id']);
$user->name = $_POST['upName'];
$newPass = password_hash($_POST['upPassword'], PASSWORD_DEFAULT);
$user->password = $newPass;
if(!empty($_POST['upName'])){
$user->name = $_POST['upName'];
}
if(!empty($_POST['upPassword'])){
$newPass = password_hash($_POST['upPassword'], PASSWORD_DEFAULT);
$user->password = $newPass;
}
if($user->update()){
return 1;