mirror of
https://github.com/penpot/penpot.git
synced 2026-04-25 11:18:36 +00:00
♻️ Move int-in-range? helper to app.common.data
Remove the private int-in-range? definition from app.auth.oidc and add it as a public utility in app.common.data, then use d/int-in-range? in both app.auth.oidc and app.media. Signed-off-by: Andrey Antukh <niwi@niwi.nz>
This commit is contained in:
parent
addc2c701b
commit
2c93387a34
@ -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"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user