0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-13 02:28:18 -05:00

🐛 Fix issues with not authenticated requests

Related to concurrency model refactor.
This commit is contained in:
Andrey Antukh 2022-02-23 12:34:08 +01:00
parent 496ba433e9
commit e15f5bb432
2 changed files with 10 additions and 19 deletions

View file

@ -114,10 +114,7 @@
(if (= :none dname)
(with-meta
(fn [cfg params]
(try
(p/wrap (f cfg params))
(catch Throwable cause
(p/rejected cause))))
(p/do! (f cfg params)))
mdata)
(let [executor (get executors dname)]
@ -173,13 +170,14 @@
(fn [{:keys [::request] :as params}]
;; Raise authentication error when rpc method requires auth but
;; no profile-id is found in the request.
(when (and auth? (not (uuid? (:profile-id params))))
(ex/raise :type :authentication
:code :authentication-required
:hint "authentication required for this endpoint"))
(p/do!
(if (and auth? (not (uuid? (:profile-id params))))
(ex/raise :type :authentication
:code :authentication-required
:hint "authentication required for this endpoint")
(let [params (us/conform spec (dissoc params ::request))]
(f cfg (assoc params ::request request))))))
(let [params (us/conform spec (dissoc params ::request))]
(f cfg (assoc params ::request request))))
mdata)))
(defn- process-method

View file

@ -29,17 +29,10 @@
(if-let [max-retries (::max-retries mdata)]
(fn [cfg params]
(letfn [(run [retry]
(prn "wrap-retry" "run" retry)
(try
(-> (f cfg params)
(p/catch (partial handle-error retry)))
(catch Throwable cause
(prn cause)
(throw cause))))
(-> (f cfg params)
(p/catch (partial handle-error retry))))
(handle-error [retry cause]
(prn "FOOFOFOF" retry (matches cause))
(if (matches cause)
(let [current-retry (inc retry)]
(l/trace :hint "running retry algorithm" :retry current-retry)