diff --git a/backend/src/app/auth/oidc.clj b/backend/src/app/auth/oidc.clj index 7668a49b99..5b74725c54 100644 --- a/backend/src/app/auth/oidc.clj +++ b/backend/src/app/auth/oidc.clj @@ -223,10 +223,6 @@ ;; GITHUB AUTH PROVIDER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(defn- int-in-range? - [val start end] - (and (<= start val) (< val end))) - (defn- lookup-github-email [cfg tdata props] (or (some-> props :github/email) @@ -237,7 +233,7 @@ {:keys [status body]} (http/req! cfg params)] - (when-not (int-in-range? status 200 300) + (when-not (d/int-in-range? status 200 300) (ex/raise :type :internal :code :unable-to-retrieve-github-emails :hint "unable to retrieve github emails" @@ -513,7 +509,7 @@ :status (:status response) :body (:body response)) - (when-not (int-in-range? (:status response) 200 300) + (when-not (d/int-in-range? (:status response) 200 300) (ex/raise :type :internal :code :unable-to-retrieve-user-info :hint "unable to retrieve user info" diff --git a/backend/src/app/media.clj b/backend/src/app/media.clj index 6bd3bf661a..27f74c1b54 100644 --- a/backend/src/app/media.clj +++ b/backend/src/app/media.clj @@ -304,7 +304,7 @@ format (cm/mtype->format mtype) max-size (cf/get :media-max-file-size default-max-file-size)] - (when-not (and (>= status 200) (< status 300)) + (when-not (d/int-in-range? status 200 300) (ex/raise :type :validation :code :unable-to-download-from-url :hint "the url returned a non-success http status" diff --git a/common/src/app/common/data.cljc b/common/src/app/common/data.cljc index 4cb6cedc60..c089a3b113 100644 --- a/common/src/app/common/data.cljc +++ b/common/src/app/common/data.cljc @@ -36,6 +36,11 @@ [size i] (and (< i size) (>= i 0))) +(defn int-in-range? + "Check if an integer val is in the range [start, end)." + [val start end] + (and (>= val start) (< val end))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Commonly used transducers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;