From b60c342a8f7d5e61d884184817e4fa8fdd849809 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 7 Nov 2021 16:45:36 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Hypolite Petovan --- include/api.php | 8 +++----- mod/settings.php | 6 +----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/include/api.php b/include/api.php index 062865d439..68723a0f42 100644 --- a/include/api.php +++ b/include/api.php @@ -239,11 +239,9 @@ function api_login(App $a) } else { try { $user_id = User::getIdFromPasswordAuthentication(trim($user), trim($password), true); - if ($user_id !== false) { - $record = DBA::selectFirst('user', [], ['uid' => $user_id]); - } - } catch (Exception $ex) { - $record = []; + $record = DBA::selectFirst('user', [], ['uid' => $user_id]); + } catch (Exception $ex) { + $record = []; } } diff --git a/mod/settings.php b/mod/settings.php index e42760358c..080bcdeb93 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -309,12 +309,8 @@ function settings_post(App $a) if ($email != $user['email']) { // check for the correct password try { - $authenticated = User::getIdFromPasswordAuthentication(intval(local_user()), $_POST['mpassword']); + User::getIdFromPasswordAuthentication(local_user(), $_POST['mpassword']); } catch (Exception $ex) { - $authenticated = false; - } - - if (!$authenticated) { $err .= DI::l10n()->t('Wrong Password.'); $email = $user['email']; }