0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 23:49:45 -05:00

Minor improvement on event syncronization on login after register.

This commit is contained in:
Andrey Antukh 2021-07-07 12:43:50 +02:00
parent 1b44fe8fec
commit 19afc2274a
2 changed files with 21 additions and 7 deletions

View file

@ -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

View file

@ -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)}))))