mirror of
https://github.com/penpot/penpot.git
synced 2025-05-18 17:36:12 +02:00
Merge remote-tracking branch 'origin/staging' into develop
This commit is contained in:
commit
d14e907954
8 changed files with 78 additions and 58 deletions
|
@ -26,25 +26,30 @@
|
||||||
|
|
||||||
(defmethod ig/init-key ::handler
|
(defmethod ig/init-key ::handler
|
||||||
[_ cfg]
|
[_ cfg]
|
||||||
(fn [request]
|
(fn [request respond _]
|
||||||
(let [body (parse-json (slurp (:body request)))
|
(try
|
||||||
mtype (get body "Type")]
|
(let [body (parse-json (slurp (:body request)))
|
||||||
(cond
|
mtype (get body "Type")]
|
||||||
(= mtype "SubscriptionConfirmation")
|
(cond
|
||||||
(let [surl (get body "SubscribeURL")
|
(= mtype "SubscriptionConfirmation")
|
||||||
stopic (get body "TopicArn")]
|
(let [surl (get body "SubscribeURL")
|
||||||
(l/info :action "subscription received" :topic stopic :url surl)
|
stopic (get body "TopicArn")]
|
||||||
(http/send! {:uri surl :method :post :timeout 10000}))
|
(l/info :action "subscription received" :topic stopic :url surl)
|
||||||
|
(http/send! {:uri surl :method :post :timeout 10000}))
|
||||||
|
|
||||||
(= mtype "Notification")
|
(= mtype "Notification")
|
||||||
(when-let [message (parse-json (get body "Message"))]
|
(when-let [message (parse-json (get body "Message"))]
|
||||||
(let [notification (parse-notification cfg message)]
|
(let [notification (parse-notification cfg message)]
|
||||||
(process-report cfg notification)))
|
(process-report cfg notification)))
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(l/warn :hint "unexpected data received"
|
(l/warn :hint "unexpected data received"
|
||||||
:report (pr-str body)))
|
:report (pr-str body))))
|
||||||
{:status 200 :body ""})))
|
(catch Throwable cause
|
||||||
|
(l/error :hint "unexpected exception on awsns handler"
|
||||||
|
:cause cause)))
|
||||||
|
|
||||||
|
(respond {:status 200 :body ""})))
|
||||||
|
|
||||||
(defn- parse-bounce
|
(defn- parse-bounce
|
||||||
[data]
|
[data]
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
;; Default thread pool for IO operations
|
;; Default thread pool for IO operations
|
||||||
[::default :app.worker/executor]
|
[::default :app.worker/executor]
|
||||||
{:parallelism (cf/get :default-executor-parallelism 120)
|
{:parallelism (cf/get :default-executor-parallelism 60)
|
||||||
:prefix :default}
|
:prefix :default}
|
||||||
|
|
||||||
;; Constrained thread pool. Should only be used from high demand
|
;; Constrained thread pool. Should only be used from high demand
|
||||||
|
@ -57,7 +57,6 @@
|
||||||
:app.migrations/all
|
:app.migrations/all
|
||||||
{:main (ig/ref :app.migrations/migrations)}
|
{:main (ig/ref :app.migrations/migrations)}
|
||||||
|
|
||||||
|
|
||||||
:app.msgbus/msgbus
|
:app.msgbus/msgbus
|
||||||
{:backend (cf/get :msgbus-backend :redis)
|
{:backend (cf/get :msgbus-backend :redis)
|
||||||
:redis-uri (cf/get :redis-uri)}
|
:redis-uri (cf/get :redis-uri)}
|
||||||
|
|
|
@ -94,7 +94,6 @@
|
||||||
(sto/put-object {:content (sto/content data)
|
(sto/put-object {:content (sto/content data)
|
||||||
:content-type mtype
|
:content-type mtype
|
||||||
:reference :file-media-object
|
:reference :file-media-object
|
||||||
:touched-at (dt/now)
|
|
||||||
:expired-at (dt/in-future {:minutes 30})}))))
|
:expired-at (dt/in-future {:minutes 30})}))))
|
||||||
|
|
||||||
;; NOTE: we use the `on conflict do update` instead of `do nothing`
|
;; NOTE: we use the `on conflict do update` instead of `do nothing`
|
||||||
|
|
|
@ -278,7 +278,9 @@
|
||||||
:opt-un [::scope ::invitation-token]))
|
:opt-un [::scope ::invitation-token]))
|
||||||
|
|
||||||
(sv/defmethod ::login
|
(sv/defmethod ::login
|
||||||
{:auth false ::rlimit/permits (cf/get :rlimit-password)}
|
{:auth false
|
||||||
|
::async/dispatch :default
|
||||||
|
::rlimit/permits (cf/get :rlimit-password)}
|
||||||
[{:keys [pool session tokens] :as cfg} {:keys [email password] :as params}]
|
[{:keys [pool session tokens] :as cfg} {:keys [email password] :as params}]
|
||||||
(letfn [(check-password [profile password]
|
(letfn [(check-password [profile password]
|
||||||
(when (= (:password profile) "!")
|
(when (= (:password profile) "!")
|
||||||
|
|
|
@ -170,13 +170,15 @@
|
||||||
(get-redirect-event))
|
(get-redirect-event))
|
||||||
(rx/observe-on :async)))))))
|
(rx/observe-on :async)))))))
|
||||||
|
|
||||||
|
(s/def ::invitation-token ::us/not-empty-string)
|
||||||
(s/def ::login-params
|
(s/def ::login-params
|
||||||
(s/keys :req-un [::email ::password]))
|
(s/keys :req-un [::email ::password]
|
||||||
|
:opt-un [::invitation-token]))
|
||||||
|
|
||||||
(declare login-from-register)
|
(declare login-from-register)
|
||||||
|
|
||||||
(defn login
|
(defn login
|
||||||
[{:keys [email password] :as data}]
|
[{:keys [email password invitation-token] :as data}]
|
||||||
(us/verify ::login-params data)
|
(us/verify ::login-params data)
|
||||||
(ptk/reify ::login
|
(ptk/reify ::login
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
|
@ -184,9 +186,10 @@
|
||||||
(let [{:keys [on-error on-success]
|
(let [{:keys [on-error on-success]
|
||||||
:or {on-error rx/throw
|
:or {on-error rx/throw
|
||||||
on-success identity}} (meta data)
|
on-success identity}} (meta data)
|
||||||
|
|
||||||
params {:email email
|
params {:email email
|
||||||
:password password
|
:password password
|
||||||
:scope "webapp"}]
|
:invitation-token invitation-token}]
|
||||||
|
|
||||||
;; NOTE: We can't take the profile value from login because
|
;; NOTE: We can't take the profile value from login because
|
||||||
;; there are cases when login is successfull but the cookie is
|
;; there are cases when login is successfull but the cookie is
|
||||||
|
@ -197,31 +200,32 @@
|
||||||
;; the returned profile is an NOT authenticated profile, we
|
;; the returned profile is an NOT authenticated profile, we
|
||||||
;; proceed to logout and show an error message.
|
;; proceed to logout and show an error message.
|
||||||
|
|
||||||
(rx/merge
|
(->> (rp/mutation :login (d/without-nils params))
|
||||||
(->> (rp/mutation :login params)
|
(rx/merge-map (fn [data]
|
||||||
(rx/map fetch-profile)
|
(rx/merge
|
||||||
(rx/catch on-error))
|
(rx/of (fetch-profile))
|
||||||
|
(->> stream
|
||||||
|
(rx/filter profile-fetched?)
|
||||||
|
(rx/take 1)
|
||||||
|
(rx/map deref)
|
||||||
|
(rx/filter (complement is-authenticated?))
|
||||||
|
(rx/tap on-error)
|
||||||
|
(rx/map #(ex/raise :type :authentication))
|
||||||
|
(rx/observe-on :async))
|
||||||
|
|
||||||
(->> stream
|
(->> stream
|
||||||
(rx/filter profile-fetched?)
|
(rx/filter profile-fetched?)
|
||||||
(rx/take 1)
|
(rx/take 1)
|
||||||
(rx/map deref)
|
(rx/map deref)
|
||||||
(rx/filter (complement is-authenticated?))
|
(rx/filter is-authenticated?)
|
||||||
(rx/tap on-error)
|
(rx/map (fn [profile]
|
||||||
(rx/map #(ex/raise :type :authentication))
|
(with-meta (merge data profile)
|
||||||
(rx/observe-on :async))
|
{::ev/source "login"})))
|
||||||
|
(rx/tap on-success)
|
||||||
|
(rx/map logged-in)
|
||||||
|
(rx/observe-on :async)))))
|
||||||
|
(rx/catch on-error))))))
|
||||||
|
|
||||||
(->> stream
|
|
||||||
(rx/filter profile-fetched?)
|
|
||||||
(rx/take 1)
|
|
||||||
(rx/map deref)
|
|
||||||
(rx/filter is-authenticated?)
|
|
||||||
(rx/map (fn [profile]
|
|
||||||
(with-meta profile
|
|
||||||
{::ev/source "login"})))
|
|
||||||
(rx/tap on-success)
|
|
||||||
(rx/map logged-in)
|
|
||||||
(rx/observe-on :async)))))))
|
|
||||||
|
|
||||||
(defn login-from-token
|
(defn login-from-token
|
||||||
[{:keys [profile] :as tdata}]
|
[{:keys [profile] :as tdata}]
|
||||||
|
|
|
@ -30,9 +30,11 @@
|
||||||
|
|
||||||
(s/def ::email ::us/email)
|
(s/def ::email ::us/email)
|
||||||
(s/def ::password ::us/not-empty-string)
|
(s/def ::password ::us/not-empty-string)
|
||||||
|
(s/def ::invitation-token ::us/not-empty-string)
|
||||||
|
|
||||||
(s/def ::login-form
|
(s/def ::login-form
|
||||||
(s/keys :req-un [::email ::password]))
|
(s/keys :req-un [::email ::password]
|
||||||
|
:opt-un [::invitation-token]))
|
||||||
|
|
||||||
(defn- login-with-oauth
|
(defn- login-with-oauth
|
||||||
[event provider params]
|
[event provider params]
|
||||||
|
@ -62,29 +64,39 @@
|
||||||
|
|
||||||
(mf/defc login-form
|
(mf/defc login-form
|
||||||
[{:keys [params] :as props}]
|
[{:keys [params] :as props}]
|
||||||
(let [error (mf/use-state false)
|
(let [initial (mf/use-memo (mf/deps params) (constantly params))
|
||||||
form (fm/use-form :spec ::login-form
|
|
||||||
:inital {})
|
error (mf/use-state false)
|
||||||
|
form (fm/use-form :spec ::login-form :initial initial)
|
||||||
|
|
||||||
on-error
|
on-error
|
||||||
(fn [_]
|
(fn [_]
|
||||||
(reset! error (tr "errors.wrong-credentials")))
|
(reset! error (tr "errors.wrong-credentials")))
|
||||||
|
|
||||||
|
on-succes
|
||||||
|
(fn [data]
|
||||||
|
(prn "SUCCESS" data)
|
||||||
|
(when-let [token (:invitation-token data)]
|
||||||
|
(st/emit! (rt/nav :auth-verify-token {} {:token token}))))
|
||||||
|
|
||||||
on-submit
|
on-submit
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(mf/deps form)
|
(fn [form _event]
|
||||||
(fn [_]
|
|
||||||
(reset! error nil)
|
(reset! error nil)
|
||||||
(let [params (with-meta (:clean-data @form)
|
(let [params (with-meta (:clean-data @form)
|
||||||
{:on-error on-error})]
|
{:on-error on-error
|
||||||
|
:on-success on-succes})]
|
||||||
(st/emit! (du/login params)))))
|
(st/emit! (du/login params)))))
|
||||||
|
|
||||||
on-submit-ldap
|
on-submit-ldap
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(mf/deps form)
|
(mf/deps form)
|
||||||
(fn [event]
|
(fn [event]
|
||||||
(let [params (merge (:clean-data @form) params)]
|
(reset! error nil)
|
||||||
(login-with-ldap event (with-meta params {:on-error on-error})))))]
|
(let [params (:clean-data @form)]
|
||||||
|
(login-with-ldap event (with-meta params
|
||||||
|
{:on-error on-error
|
||||||
|
:on-success on-succes})))))]
|
||||||
|
|
||||||
[:*
|
[:*
|
||||||
(when-let [message @error]
|
(when-let [message @error]
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
:email-already-exists
|
:email-already-exists
|
||||||
(swap! form assoc-in [:errors :email]
|
(swap! form assoc-in [:errors :email]
|
||||||
{:message "errors.email-already-exists"})
|
{:message "errors.email-already-exists"})
|
||||||
|
|
||||||
:email-as-password
|
:email-as-password
|
||||||
(swap! form assoc-in [:errors :password]
|
(swap! form assoc-in [:errors :password]
|
||||||
{:message "errors.email-as-password"})
|
{:message "errors.email-as-password"})
|
||||||
|
|
|
@ -174,7 +174,6 @@
|
||||||
[{:keys [options label form default data-test] :as props
|
[{:keys [options label form default data-test] :as props
|
||||||
:or {default ""}}]
|
:or {default ""}}]
|
||||||
(let [input-name (get props :name)
|
(let [input-name (get props :name)
|
||||||
|
|
||||||
form (or form (mf/use-ctx form-ctx))
|
form (or form (mf/use-ctx form-ctx))
|
||||||
value (or (get-in @form [:data input-name]) default)
|
value (or (get-in @form [:data input-name]) default)
|
||||||
cvalue (d/seek #(= value (:value %)) options)
|
cvalue (d/seek #(= value (:value %)) options)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue