diff --git a/frontend/src/app/main/data/users.cljs b/frontend/src/app/main/data/users.cljs index 32a81d39d..b1fc5b796 100644 --- a/frontend/src/app/main/data/users.cljs +++ b/frontend/src/app/main/data/users.cljs @@ -138,9 +138,7 @@ ptk/WatchEvent (watch [_ _ _] - (let [team-id (get-current-team-id profile) - profile (with-meta profile - {::ev/source "login"})] + (let [team-id (get-current-team-id profile)] (->> (rx/concat (rx/of (profile-fetched profile) (fetch-teams)) @@ -187,6 +185,25 @@ (with-meta profile {::ev/source "login-with-token"})))))) +(defn login-from-register + "Event used mainly for mark current session as logged-in in after the + user sucessfully registred using third party auth provider (in this + case we dont need to verify the email)." + [] + (ptk/reify ::login-from-register + ptk/WatchEvent + (watch [_ _ stream] + (rx/merge + (rx/of (fetch-profile)) + (->> stream + (rx/filter (ptk/type? ::profile-fetched)) + (rx/take 1) + (rx/map deref) + (rx/map (fn [profile] + (with-meta profile + {::ev/source "register"}))) + (rx/map logged-in)))))) + ;; --- EVENT: logout (defn logged-out diff --git a/frontend/src/app/main/ui/auth/register.cljs b/frontend/src/app/main/ui/auth/register.cljs index fcc619c11..5ee5ebd1f 100644 --- a/frontend/src/app/main/ui/auth/register.cljs +++ b/frontend/src/app/main/ui/auth/register.cljs @@ -169,11 +169,8 @@ (let [token (:invitation-token data)] (st/emit! (rt/nav :auth-verify-token {} {:token token}))) - (not= "penpot" (:auth-backend data)) - (st/emit! - (du/fetch-profile) - (rt/nav :dashboard-projects {:team-id (:default-team-id data)})) + (st/emit! (du/login-from-register)) :else (st/emit! (rt/nav :auth-register-success {} {:email (:email data)}))))