From 0654741e28feae5e5fbfeb022dbb31d53a60cf2d Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Thu, 16 Jun 2022 17:16:33 +0200 Subject: [PATCH] :tada: Navigate to the original link after log in --- CHANGES.md | 1 + frontend/src/app/main/data/users.cljs | 9 +++++++-- frontend/src/app/main/errors.cljs | 7 +++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 90fedeb5c..af95b168f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,6 +10,7 @@ - Multiple team invitations on onboarding [Taiga #3084](https://tree.taiga.io/project/penpot/us/3084) - Change text properties position at the sidebar [Taiga #3047](https://tree.taiga.io/project/penpot/us/3047) - Group assets by drag and drop [Taiga #2831](https://tree.taiga.io/project/penpot/us/2831) +- Navigate to the original link after log in [Taiga #3624](https://tree.taiga.io/project/penpot/issue/3624) ### :bug: Bugs fixed - Fix menu file not accessible in certain conditions [Taiga #3385](https://tree.taiga.io/project/penpot/issue/3385) diff --git a/frontend/src/app/main/data/users.cljs b/frontend/src/app/main/data/users.cljs index 1eaa37d84..275c4b194 100644 --- a/frontend/src/app/main/data/users.cljs +++ b/frontend/src/app/main/data/users.cljs @@ -157,8 +157,13 @@ accepting invitation, or third party auth signup or singin." [profile] (letfn [(get-redirect-event [] - (let [team-id (:default-team-id profile)] - (rt/nav' :dashboard-projects {:team-id team-id})))] + (let [team-id (:default-team-id profile) + redirect-url (:redirect-url @storage)] + (if (some? redirect-url) + (do + (swap! storage dissoc :redirect-url) + (.replace js/location redirect-url)) + (rt/nav' :dashboard-projects {:team-id team-id}))))] (ptk/reify ::logged-in IDeref (-deref [_] profile) diff --git a/frontend/src/app/main/errors.cljs b/frontend/src/app/main/errors.cljs index 604b0b039..674dfb3ea 100644 --- a/frontend/src/app/main/errors.cljs +++ b/frontend/src/app/main/errors.cljs @@ -19,6 +19,7 @@ [app.util.globals :as glob] [app.util.i18n :refer [tr]] [app.util.router :as rt] + [app.util.storage :refer [storage]] [app.util.timers :as ts] [potok.core :as ptk])) @@ -49,9 +50,11 @@ ;; here and not in app.main.errors because of circular dependency. (defmethod ptk/handle-error :authentication [_] - (let [msg (tr "errors.auth.unable-to-login")] + (let [msg (tr "errors.auth.unable-to-login") + uri (. (. js/document -location) -href)] (st/emit! (du/logout {:capture-redirect true})) - (ts/schedule 500 #(st/emit! (msg/warn msg))))) + (ts/schedule 500 #(st/emit! (msg/warn msg))) + (ts/schedule 1000 #(swap! storage assoc :redirect-url uri)))) ;; Error that happens on an active business model validation does not ;; passes an validation (example: profile can't leave a team). From