0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-06 14:50:20 -05:00

🐛 Fix incorrect team invitation redirect after login

This commit is contained in:
Andrey Antukh 2024-12-13 10:22:40 +01:00
parent 1b2a38351d
commit eaec46a67b
2 changed files with 21 additions and 26 deletions

View file

@ -39,24 +39,26 @@
accepting invitation, or third party auth signup or singin." accepting invitation, or third party auth signup or singin."
[{:keys [props] :as profile}] [{:keys [props] :as profile}]
(letfn [(get-redirect-events [teams] (letfn [(get-redirect-events [teams]
(if-let [redirect-href (:login-redirect storage/session)] (if-let [token (:invitation-token profile)]
(binding [storage/*sync* true] (rx/of (rt/nav :auth-verify-token {:token token}))
(swap! storage/session dissoc :login-redirect) (if-let [redirect-href (:login-redirect storage/session)]
(if (= redirect-href (rt/get-current-href)) (binding [storage/*sync* true]
(rx/of (rt/reload true)) (swap! storage/session dissoc :login-redirect)
(rx/of (rt/nav-raw :href redirect-href)))) (if (= redirect-href (rt/get-current-href))
(if-let [file-id (get props :welcome-file-id)] (rx/of (rt/reload true))
(rx/of (dcm/go-to-workspace (rx/of (rt/nav-raw :href redirect-href))))
:file-id file-id (if-let [file-id (get props :welcome-file-id)]
:team-id (:default-team-id profile)) (rx/of (dcm/go-to-workspace
(dp/update-profile-props {:welcome-file-id nil})) :file-id file-id
:team-id (:default-team-id profile))
(dp/update-profile-props {:welcome-file-id nil}))
(let [teams (into #{} (map :id) teams) (let [teams (into #{} (map :id) teams)
team-id (dtm/get-last-team-id) team-id (dtm/get-last-team-id)
team-id (if (and team-id (contains? teams team-id)) team-id (if (and team-id (contains? teams team-id))
team-id team-id
(:default-team-id profile))] (:default-team-id profile))]
(rx/of (dcm/go-to-dashboard-recent {:team-id team-id}))))))] (rx/of (dcm/go-to-dashboard-recent {:team-id team-id})))))))]
(ptk/reify ::logged-in (ptk/reify ::logged-in
ev/Event ev/Event

View file

@ -120,17 +120,10 @@
:else :else
(reset! error (tr "errors.generic"))))) (reset! error (tr "errors.generic")))))
on-success-default
(mf/use-fn
(fn [data]
(when-let [token (:invitation-token data)]
(st/emit! (rt/nav :auth-verify-token {:token token})))))
on-success on-success
(fn [data] (fn [data]
(if (nil? on-success-callback) (when (fn? on-success-callback)
(on-success-default data) (on-success-callback data)))
(on-success-callback)))
on-submit on-submit
(mf/use-callback (mf/use-callback