Made admin clients easier to work with.
This commit is contained in:
@@ -40,27 +40,27 @@
|
||||
(cond
|
||||
(= :login handler)
|
||||
{:db (assoc db/default-db
|
||||
:active-page :login
|
||||
:active-route :login
|
||||
:last-client-id (.getItem js/localStorage "last-client-id")
|
||||
:user nil)}
|
||||
|
||||
(and (not= :login handler) (not token))
|
||||
{:redirect "/login"
|
||||
:db (assoc db/default-db
|
||||
:active-page :login
|
||||
:active-route :login
|
||||
:last-client-id (.getItem js/localStorage "last-client-id")
|
||||
:user token)}
|
||||
|
||||
(and token (= "none" (or (get (jwt->data token) "role") (get (jwt->data token) "user/role")) ))
|
||||
{:redirect "/needs-activation"
|
||||
:db (assoc db/default-db
|
||||
:active-page :needs-activation
|
||||
:active-route :needs-activation
|
||||
:last-client-id (.getItem js/localStorage "last-client-id")
|
||||
:user token)}
|
||||
|
||||
:else
|
||||
{:db (assoc db/default-db
|
||||
:active-page handler
|
||||
:active-route handler
|
||||
:is-initial-loading? true
|
||||
:last-client-id (.getItem js/localStorage "last-client-id")
|
||||
:query-params (auto-ap.views.utils/query-params)
|
||||
@@ -123,7 +123,7 @@
|
||||
(assoc db :initial-error e
|
||||
|
||||
:is-initial-loading? false
|
||||
:active-page :initial-error)))
|
||||
:active-route :initial-error)))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::swap-client
|
||||
@@ -140,20 +140,19 @@
|
||||
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::set-active-page
|
||||
(fn [{:keys [db]} [_ handler params]]
|
||||
::set-active-route
|
||||
(fn [{:keys [db]} [_ handler params route-params]]
|
||||
|
||||
|
||||
(if (and (not= :login handler) (not (:user db)))
|
||||
{:redirect "/login"
|
||||
:db (assoc db :active-page :login
|
||||
:page-failure nil
|
||||
:auto-ap.forms/forms nil)}
|
||||
:db (assoc db :active-route :login
|
||||
:page-failure nil)}
|
||||
{:db (-> db
|
||||
(assoc :active-page handler
|
||||
(assoc :active-route handler
|
||||
:page-failure nil
|
||||
:query-params params
|
||||
:auto-ap.forms/forms nil)
|
||||
:route-params route-params)
|
||||
(auto-ap.views.pages.data-page/dispose-all))})))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user