mirror of
https://github.com/penpot/penpot.git
synced 2025-01-27 00:49:28 -05:00
✨ Minor improvement on event syncronization on login after register.
This commit is contained in:
parent
1b44fe8fec
commit
19afc2274a
2 changed files with 21 additions and 7 deletions
|
@ -138,9 +138,7 @@
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ _ _]
|
(watch [_ _ _]
|
||||||
(let [team-id (get-current-team-id profile)
|
(let [team-id (get-current-team-id profile)]
|
||||||
profile (with-meta profile
|
|
||||||
{::ev/source "login"})]
|
|
||||||
(->> (rx/concat
|
(->> (rx/concat
|
||||||
(rx/of (profile-fetched profile)
|
(rx/of (profile-fetched profile)
|
||||||
(fetch-teams))
|
(fetch-teams))
|
||||||
|
@ -187,6 +185,25 @@
|
||||||
(with-meta profile
|
(with-meta profile
|
||||||
{::ev/source "login-with-token"}))))))
|
{::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
|
;; --- EVENT: logout
|
||||||
|
|
||||||
(defn logged-out
|
(defn logged-out
|
||||||
|
|
|
@ -169,11 +169,8 @@
|
||||||
(let [token (:invitation-token data)]
|
(let [token (:invitation-token data)]
|
||||||
(st/emit! (rt/nav :auth-verify-token {} {:token token})))
|
(st/emit! (rt/nav :auth-verify-token {} {:token token})))
|
||||||
|
|
||||||
|
|
||||||
(not= "penpot" (:auth-backend data))
|
(not= "penpot" (:auth-backend data))
|
||||||
(st/emit!
|
(st/emit! (du/login-from-register))
|
||||||
(du/fetch-profile)
|
|
||||||
(rt/nav :dashboard-projects {:team-id (:default-team-id data)}))
|
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(st/emit! (rt/nav :auth-register-success {} {:email (:email data)}))))
|
(st/emit! (rt/nav :auth-register-success {} {:email (:email data)}))))
|
||||||
|
|
Loading…
Add table
Reference in a new issue