0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 07:29:08 -05:00

Merge pull request #5108 from penpot/palba-fix-login-redirect

🐛 Fix bad redirect on new oops page with penpot login
This commit is contained in:
Alejandro 2024-09-24 11:27:04 +02:00 committed by GitHub
commit 91c8af9e38
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 11 deletions

View file

@ -170,13 +170,16 @@
(letfn [(get-redirect-events [] (letfn [(get-redirect-events []
(let [team-id (get-current-team-id profile) (let [team-id (get-current-team-id profile)
welcome-file-id (dm/get-in profile [:props :welcome-file-id]) welcome-file-id (dm/get-in profile [:props :welcome-file-id])
redirect-href (:login-redirect @s/session)] redirect-href (:login-redirect @s/session)
current-href (rt/get-current-href)]
(cond (cond
(some? redirect-href) (some? redirect-href)
(binding [s/*sync* true] (binding [s/*sync* true]
(swap! s/session dissoc :login-redirect) (swap! s/session dissoc :login-redirect)
(rx/of (rt/nav-raw :href redirect-href))) (if (= current-href redirect-href)
(rx/of (rt/reload true))
(rx/of (rt/nav-raw :href redirect-href))))
(some? welcome-file-id) (some? welcome-file-id)
(rx/of (rt/nav' :workspace {:project-id (:default-project-id profile) (rx/of (rt/nav' :workspace {:project-id (:default-project-id profile)

View file

@ -45,18 +45,22 @@
[] []
(st/emit! (du/create-demo-profile))) (st/emit! (du/create-demo-profile)))
(defn- login-with-oidc (defn- store-login-redirect
[event provider params] [save-login-redirect]
(dom/prevent-default event)
(binding [s/*sync* true] (binding [s/*sync* true]
(if (some? (:save-login-redirect params)) (if (some? save-login-redirect)
;; Save the current login raw uri for later redirect user back to ;; Save the current login raw uri for later redirect user back to
;; the same page, we need it to be synchronous because the user is ;; the same page, we need it to be synchronous because the user is
;; going to be redirected instantly to the oidc provider uri ;; going to be redirected instantly to the oidc provider uri
(swap! s/session assoc :login-redirect (rt/get-current-href)) (swap! s/session assoc :login-redirect (rt/get-current-href))
;; Clean the login redirect ;; Clean the login redirect
(swap! s/session dissoc :login-redirect))) (swap! s/session dissoc :login-redirect))))
(defn- login-with-oidc
[event provider params]
(dom/prevent-default event)
(store-login-redirect (:save-login-redirect params))
;; FIXME: this code should be probably moved outside of the UI ;; FIXME: this code should be probably moved outside of the UI
(->> (rp/cmd! :login-with-oidc (assoc params :provider provider)) (->> (rp/cmd! :login-with-oidc (assoc params :provider provider))
@ -131,6 +135,7 @@
on-submit on-submit
(mf/use-callback (mf/use-callback
(fn [form _event] (fn [form _event]
(store-login-redirect (:save-login-redirect params))
(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

View file

@ -31,7 +31,7 @@
(defn asap (defn asap
[f] [f]
(-> (p/resolved nil) (-> (p/resolved nil)
(p/then f))) (p/then (fn [_] (f)))))
(defn interval (defn interval
[ms func] [ms func]