From 59f91682a7f92698004d06e95239a7d72523849a Mon Sep 17 00:00:00 2001 From: Victor Date: Wed, 9 Jun 2021 12:47:36 +0200 Subject: [PATCH] v0.1.5bc Try to fix user update with empty text box --- Backend/controller/updateUser.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Backend/controller/updateUser.php b/Backend/controller/updateUser.php index e3c88d6..56289a3 100644 --- a/Backend/controller/updateUser.php +++ b/Backend/controller/updateUser.php @@ -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;