diff --git a/frontend/src/app/main.cljs b/frontend/src/app/main.cljs index a5162d8cd..2498735e3 100644 --- a/frontend/src/app/main.cljs +++ b/frontend/src/app/main.cljs @@ -11,6 +11,7 @@ (:require [app.common.uuid :as uuid] [app.common.spec :as us] + [app.main.repo :as rp] [app.main.data.auth :refer [logout]] [app.main.data.users :as udu] [app.main.store :as st] @@ -51,10 +52,21 @@ (defn on-navigate [router path] - (let [match (match-path router path)] + (let [match (match-path router path) + profile (:profile storage) + nopath? (or (= path "") (= path "/")) + authed? (and (not (nil? profile)) + (not= (:id profile) uuid/zero))] + (cond - (or (= path "") - (nil? match)) + (and nopath? authed? (nil? match)) + (->> (rp/query! :profile) + (rx/subs (fn [profile] + (if (not= uuid/zero profile) + (st/emit! (rt/nav :dashboard-projects {:team-id (:default-team-id profile)})) + (st/emit! (rt/nav :auth-login)))))) + + (and (not authed?) (nil? match)) (st/emit! (rt/nav :auth-login)) (nil? match)