From 1c6535c0b45c32ccbb0e2bd49e5bb7a6d5435d27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Mon, 23 Jan 2017 09:44:53 +0100 Subject: [PATCH] applied coding convention: - replaced space -> tab (code indenting) - added curly braces - used dbm::is_result() if $r is no result (may happen) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- mod/settings.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/mod/settings.php b/mod/settings.php index 32ccaf541a..94b93f9b95 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -381,13 +381,15 @@ function settings_post(App $a) { $err = true; } - // check if the old password was supplied correctly before - // changing it to the new value - $r = q("SELECT `password` FROM `user`WHERE `uid` = %d LIMIT 1", intval(local_user())); - if( $oldpass != $r[0]['password'] ) { - notice( t('Wrong password.') . EOL); - $err = true; - } + // check if the old password was supplied correctly before + // changing it to the new value + $r = q("SELECT `password` FROM `user`WHERE `uid` = %d LIMIT 1", intval(local_user())); + if (!dbm::is_result($r)) { + killme(); + } elseif ( $oldpass != $r[0]['password'] ) { + notice( t('Wrong password.') . EOL); + $err = true; + } if(! $err) { $password = hash('whirlpool',$newpass); @@ -395,10 +397,11 @@ function settings_post(App $a) { dbesc($password), intval(local_user()) ); - if($r) + if($r) { info( t('Password changed.') . EOL); - else + } else { notice( t('Password update failed. Please try again.') . EOL); + } } }