From ac934ca94370f5204319f88eef0a7747fe7e133a Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 19 Apr 2020 13:47:34 +0200 Subject: Reclassify various exceptions as UserInputException These are errors that a user can correct themselves so we should classify them accordingly. That way they get the correct HTTP status code and they also get ignored by the logging code. Signed-off-by: Florian Pritz --- application/controllers/User.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'application/controllers/User.php') diff --git a/application/controllers/User.php b/application/controllers/User.php index c98784d50..00d348240 100644 --- a/application/controllers/User.php +++ b/application/controllers/User.php @@ -326,7 +326,7 @@ class User extends MY_Controller { $username = $this->input->post("username"); if (!$this->muser->username_exists($username)) { - throw new \exceptions\PublicApiException("user/reset_password/invalid-username", "Invalid username"); + throw new \exceptions\UserInputException("user/reset_password/invalid-username", "Invalid username"); } $userinfo = $this->db->select('id, email, username') @@ -485,18 +485,18 @@ class User extends MY_Controller { $values = explode("-", $value); if (!is_array($values) || count($values) != 2) { - throw new \exceptions\PublicApiException("user/profile/invalid-upload-id-limit", "Invalid upload id limit value"); + throw new \exceptions\UserInputException("user/profile/invalid-upload-id-limit", "Invalid upload id limit value"); } $lower = intval($values[0]); $upper = intval($values[1]); if ($lower > $upper) { - throw new \exceptions\PublicApiException("user/profile/lower-bigger-than-upper", "lower limit > upper limit"); + throw new \exceptions\UserInputException("user/profile/lower-bigger-than-upper", "lower limit > upper limit"); } if ($lower < 3 || $upper > 64) { - throw new \exceptions\PublicApiException("user/profile/limit-out-of-bounds", "upper or lower limit out of bounds (3-64)"); + throw new \exceptions\UserInputException("user/profile/limit-out-of-bounds", "upper or lower limit out of bounds (3-64)"); } return $lower."-".$upper; @@ -512,7 +512,7 @@ class User extends MY_Controller { } if (!$this->muser->valid_email($value)) { - throw new \exceptions\PublicApiException("user/profile/invalid-email", "Invalid email"); + throw new \exceptions\UserInputException("user/profile/invalid-email", "Invalid email"); } $this->load->library("email"); -- cgit v1.2.3-24-g4f1b