From cc3abea77a197cbab4c3f36243607937870332ca Mon Sep 17 00:00:00 2001 From: ssl Date: Mon, 30 Jan 2023 21:13:33 +0100 Subject: [PATCH] Corrects all error message stylings --- app/controllers/Account.php | 14 +++++++------- app/controllers/Api.php | 6 +++--- app/controllers/Settings.php | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/controllers/Account.php b/app/controllers/Account.php index cad02613..46496da2 100644 --- a/app/controllers/Account.php +++ b/app/controllers/Account.php @@ -141,7 +141,7 @@ public function mfa() $user = $this->model('User')->login($username, $password); if (getAuthCode($user['secret']) != $code) { - throw new Exception('Code is incorrect.'); + throw new Exception('Code is incorrect'); } $this->session->createSession($user); @@ -168,11 +168,11 @@ private function passwordSettings($currentPassword, $newPassword, $newPassword2) $user = $this->model('User')->getById($this->session->data('id')); if (!password_verify($currentPassword, $user['password'])) { - throw new Exception('Current password is not correct.'); + throw new Exception('Current password is incorrect'); } if ($newPassword !== $newPassword2) { - throw new Exception('The retyped password is not the same as the new password.'); + throw new Exception('The retyped password is not the same as the new password'); } $this->model('User')->setPassword($user['id'], $newPassword); @@ -193,7 +193,7 @@ private function mfaSettings($secret, $code) if (strlen($secret) == 16) { if (strlen($secretCode) === 16) { - throw new Exception('2FA settings are already enabled.'); + throw new Exception('2FA settings are already enabled'); } if (strlen($secret) !== 16) { @@ -205,11 +205,11 @@ private function mfaSettings($secret, $code) } } else { if (strlen($secretCode) !== 16) { - throw new Exception('2FA settings are already disabled.'); + throw new Exception('2FA settings are already disabled'); } if (getAuthCode($secretCode) != $code) { - throw new Exception('Code is incorrect.'); + throw new Exception('Code is incorrect'); } $secret = ''; } @@ -232,7 +232,7 @@ private function alertSettings() $mailOn = $this->getPostValue('mailon'); $mail = $this->getPostValue('mail'); if (!filter_var($mail, FILTER_VALIDATE_EMAIL) && !empty($mail)) { - throw new Exception('This is not a correct email address.'); + throw new Exception('This is not a correct email address'); } $alerts->set($user['id'], 1, $mailOn !== null, $mail); diff --git a/app/controllers/Api.php b/app/controllers/Api.php index ff7405cf..f49b1813 100644 --- a/app/controllers/Api.php +++ b/app/controllers/Api.php @@ -31,7 +31,7 @@ public function getAlertStatus() $alertId = $this->getPostValue('alertId'); if (!is_string($alertId) || !isset($alertIds[$alertId])) { - throw new Exception("Invalid alert"); + throw new Exception('Invalid alert'); } $enabled = $this->model('Setting')->get('alert-' . $alertIds[$alertId]); @@ -62,7 +62,7 @@ public function getChatId() // Check if result is OK if ($results['ok'] !== true) { - return $this->showEcho('Something went wrong. Your bot token is probably invalid.'); + return $this->showEcho('Something went wrong, your bot token is probably invalid'); } // Check if result contains any chat @@ -88,7 +88,7 @@ public function getMostCommon() // Validate if id and row is correct if (!in_array($id, [1, 2, 3, 4, 5]) || !in_array($row, [1, 2])) { - return $this->showEcho('Something went wrong.'); + return $this->showEcho('Something went wrong'); } // Save row/id combination of user diff --git a/app/controllers/Settings.php b/app/controllers/Settings.php index 6d810204..381b9b69 100644 --- a/app/controllers/Settings.php +++ b/app/controllers/Settings.php @@ -135,18 +135,18 @@ private function applicationSettings($timezone, $theme, $filter, $dompart) { // Validate timezone if (!in_array($timezone, timezone_identifiers_list(), true)) { - throw new Exception('The timezone is not a valid timezone.'); + throw new Exception('The timezone is not a valid timezone'); } // Validate if theme exists $theme = preg_replace('/[^a-zA-Z0-9]/', '', $theme); if (!file_exists(__DIR__ . "/../../assets/css/{$theme}.css")) { - throw new Exception('This theme is not installed.'); + throw new Exception('This theme is not installed'); } // Check if type is digit if (!ctype_digit($dompart)) { - throw new Exception('The dom length needs to be digits.'); + throw new Exception('The dom length needs to be digits'); } // Set the value based on the posted filter @@ -195,7 +195,7 @@ private function alertSettings() $mailOn = $this->getPostValue('mailon'); $mail = $this->getPostValue('mail'); if (!filter_var($mail, FILTER_VALIDATE_EMAIL) && !empty($mail)) { - throw new Exception('This is not a correct email address.'); + throw new Exception('This is not a correct email address'); } $alerts->set(0, 1, $mailOn !== null, $mail);