Updates for users.

This commit is contained in:
Bryce Covert
2019-02-15 15:51:16 -08:00
parent a86b7c03bf
commit 12eb4bdd41
3 changed files with 24 additions and 17 deletions

View File

@@ -18,7 +18,7 @@
::initialize-db
(fn [{:keys [db]} [_ token]]
(let [handler (:handler (bidi/match-route routes/routes (.. js/window -location -pathname)))]
(prn (and token (jwt->data token)))
(prn (and token (get (jwt->data token) "user/role")))
(cond
(and (not= :login handler) (not token))
{:redirect "/login"
@@ -26,7 +26,7 @@
:active-page :login
:user token)}
(and token (= "none" (get (jwt->data token) "role") ))
(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
@@ -77,7 +77,8 @@
(fn [db [_ {clients :client vendors :vendor :as x}]]
(-> db
(assoc :clients (by :id clients) )
(assoc :vendors (by :id vendors) ))))
(assoc :vendors (by :id vendors) )
(assoc :client (when (= 1 (count clients)) (->> clients first :id ))))))
(re-frame/reg-event-db
::swap-client