fixed login loop.

This commit is contained in:
2022-07-19 08:45:14 -07:00
parent cab3a84903
commit 483e9ad311
2 changed files with 15 additions and 9 deletions

View File

@@ -142,12 +142,17 @@
(re-frame/reg-event-fx
::set-active-route
(fn [{:keys [db]} [_ handler params route-params]]
(println "HANDELR IS" handler (:user db))
(if (and (not= :login handler) (not (:user db)))
{:redirect "/login"
:db (assoc db :active-route :login
:page-failure nil)}
(cond
(and (not= :login handler) (not (:user db)))
{:redirect (bidi/path-for routes/routes :login)
:db (assoc db :active-route :login
:active-page :login
:page-failure nil)}
:else
{:db (-> db
(assoc :active-route handler
:page-failure nil

View File

@@ -144,8 +144,9 @@
(let [ap (re-frame/subscribe [::subs/active-page])
current-client @(re-frame/subscribe [::subs/client])
is-loading? @(re-frame/subscribe [::subs/is-initial-loading?])]
(if is-loading?
[loading-layout]
[:div
^{:key (str @ap "-" current-client)} [page @ap]])))
(when @ap
(if is-loading?
[loading-layout]
[:div
^{:key (str @ap "-" current-client)} [page @ap]]))))