mirror of
https://github.com/penpot/penpot.git
synced 2025-01-23 23:18:48 -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:
commit
91c8af9e38
3 changed files with 19 additions and 11 deletions
|
@ -170,13 +170,16 @@
|
|||
(letfn [(get-redirect-events []
|
||||
(let [team-id (get-current-team-id profile)
|
||||
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
|
||||
(some? redirect-href)
|
||||
(binding [s/*sync* true]
|
||||
(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)
|
||||
(rx/of (rt/nav' :workspace {:project-id (:default-project-id profile)
|
||||
|
|
|
@ -45,18 +45,22 @@
|
|||
[]
|
||||
(st/emit! (du/create-demo-profile)))
|
||||
|
||||
(defn- store-login-redirect
|
||||
[save-login-redirect]
|
||||
(binding [s/*sync* true]
|
||||
(if (some? save-login-redirect)
|
||||
;; 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
|
||||
;; going to be redirected instantly to the oidc provider uri
|
||||
(swap! s/session assoc :login-redirect (rt/get-current-href))
|
||||
;; Clean the login redirect
|
||||
(swap! s/session dissoc :login-redirect))))
|
||||
|
||||
(defn- login-with-oidc
|
||||
[event provider params]
|
||||
(dom/prevent-default event)
|
||||
|
||||
(binding [s/*sync* true]
|
||||
(if (some? (:save-login-redirect params))
|
||||
;; 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
|
||||
;; going to be redirected instantly to the oidc provider uri
|
||||
(swap! s/session assoc :login-redirect (rt/get-current-href))
|
||||
;; Clean the login redirect
|
||||
(swap! s/session dissoc :login-redirect)))
|
||||
(store-login-redirect (:save-login-redirect params))
|
||||
|
||||
;; FIXME: this code should be probably moved outside of the UI
|
||||
(->> (rp/cmd! :login-with-oidc (assoc params :provider provider))
|
||||
|
@ -131,6 +135,7 @@
|
|||
on-submit
|
||||
(mf/use-callback
|
||||
(fn [form _event]
|
||||
(store-login-redirect (:save-login-redirect params))
|
||||
(reset! error nil)
|
||||
(let [params (with-meta (:clean-data @form)
|
||||
{:on-error on-error
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
(defn asap
|
||||
[f]
|
||||
(-> (p/resolved nil)
|
||||
(p/then f)))
|
||||
(p/then (fn [_] (f)))))
|
||||
|
||||
(defn interval
|
||||
[ms func]
|
||||
|
|
Loading…
Add table
Reference in a new issue