mirror of
https://github.com/penpot/penpot.git
synced 2025-03-11 07:11:32 -05:00
✨ Forward external session id to backend
This commit is contained in:
parent
5eee1cdbf3
commit
00b4013385
4 changed files with 21 additions and 8 deletions
|
@ -141,6 +141,7 @@
|
||||||
(::rpc/profile-id params)
|
(::rpc/profile-id params)
|
||||||
uuid/zero)
|
uuid/zero)
|
||||||
|
|
||||||
|
session-id (rreq/get-header request "x-external-session-id")
|
||||||
props (-> (or (::replace-props resultm)
|
props (-> (or (::replace-props resultm)
|
||||||
(-> params
|
(-> params
|
||||||
(merge (::props resultm))
|
(merge (::props resultm))
|
||||||
|
@ -150,8 +151,10 @@
|
||||||
(clean-props))
|
(clean-props))
|
||||||
|
|
||||||
token-id (::actoken/id request)
|
token-id (::actoken/id request)
|
||||||
context (d/without-nils
|
context (-> (::context resultm)
|
||||||
{:access-token-id (some-> token-id str)})]
|
(assoc :external-session-id session-id)
|
||||||
|
(assoc :access-token-id (some-> token-id str))
|
||||||
|
(d/without-nils))]
|
||||||
|
|
||||||
{::type (or (::type resultm)
|
{::type (or (::type resultm)
|
||||||
(::rpc/type cfg))
|
(::rpc/type cfg))
|
||||||
|
|
|
@ -130,9 +130,16 @@
|
||||||
(def worker-uri
|
(def worker-uri
|
||||||
(obj/get global "penpotWorkerURI" "/js/worker.js"))
|
(obj/get global "penpotWorkerURI" "/js/worker.js"))
|
||||||
|
|
||||||
(defn external-feature-flag [flag value]
|
(defn external-feature-flag
|
||||||
(when-let [fn (obj/get global "externalFeatureFlag")]
|
[flag value]
|
||||||
(fn flag value)))
|
(let [f (obj/get global "externalFeatureFlag")]
|
||||||
|
(when (fn? f)
|
||||||
|
(f flag value))))
|
||||||
|
|
||||||
|
(defn external-session-id
|
||||||
|
[]
|
||||||
|
(let [f (obj/get global "externalSessionId")]
|
||||||
|
(when (fn? f) (f))))
|
||||||
|
|
||||||
;; --- Helper Functions
|
;; --- Helper Functions
|
||||||
|
|
||||||
|
|
|
@ -168,7 +168,7 @@
|
||||||
ptk/EffectEvent
|
ptk/EffectEvent
|
||||||
(effect [_ _ stream]
|
(effect [_ _ stream]
|
||||||
(let [session (atom nil)
|
(let [session (atom nil)
|
||||||
stopper (rx/filter (ptk/type? ::initialize) stream)
|
stopper (rx/filter (ptk/type? ::initialize) stream)
|
||||||
buffer (atom #queue [])
|
buffer (atom #queue [])
|
||||||
profile (->> (rx/from-atom storage {:emit-current-value? true})
|
profile (->> (rx/from-atom storage {:emit-current-value? true})
|
||||||
(rx/map :profile)
|
(rx/map :profile)
|
||||||
|
@ -213,7 +213,9 @@
|
||||||
(let [session* (or @session (dt/now))
|
(let [session* (or @session (dt/now))
|
||||||
context (-> @context
|
context (-> @context
|
||||||
(merge (:context event))
|
(merge (:context event))
|
||||||
(assoc :session session*))]
|
(assoc :session session*)
|
||||||
|
(assoc :external-session-id (cf/external-session-id))
|
||||||
|
(d/without-nils))]
|
||||||
(reset! session session*)
|
(reset! session session*)
|
||||||
(-> event
|
(-> event
|
||||||
(assoc :timestamp (dt/now))
|
(assoc :timestamp (dt/now))
|
||||||
|
|
|
@ -97,7 +97,8 @@
|
||||||
request {:method method
|
request {:method method
|
||||||
:uri (u/join cf/public-uri "api/rpc/command/" nid)
|
:uri (u/join cf/public-uri "api/rpc/command/" nid)
|
||||||
:credentials "include"
|
:credentials "include"
|
||||||
:headers {"accept" "application/transit+json,text/event-stream,*/*"}
|
:headers {"accept" "application/transit+json,text/event-stream,*/*"
|
||||||
|
"x-external-session-id" (cf/external-session-id)}
|
||||||
:body (when (= method :post)
|
:body (when (= method :post)
|
||||||
(if form-data?
|
(if form-data?
|
||||||
(http/form-data params)
|
(http/form-data params)
|
||||||
|
|
Loading…
Add table
Reference in a new issue