users are not activated, looks like you can edit existing ones
This commit is contained in:
@@ -5,17 +5,31 @@
|
||||
[auto-ap.routes :as routes]
|
||||
[auto-ap.effects :as effects]
|
||||
[venia.core :as v]
|
||||
[bidi.bidi :as bidi]))
|
||||
[bidi.bidi :as bidi]
|
||||
[goog.crypt.base64 :as b64]
|
||||
[clojure.string :as str]))
|
||||
|
||||
(defn jwt->data [token]
|
||||
(js->clj (.parse js/JSON (b64/decodeString (second (str/split token #"\." ))))))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::initialize-db
|
||||
(fn [{:keys [db]} [_ token]]
|
||||
(let [handler (:handler (bidi/match-route routes/routes (.. js/window -location -pathname)))]
|
||||
(if (and (not= :login handler) (not token))
|
||||
(cond
|
||||
(and (not= :login handler) (not token))
|
||||
{:redirect "/login"
|
||||
:db (assoc db/default-db
|
||||
:active-page :login
|
||||
:user token)}
|
||||
|
||||
(and token (= "none" (get (jwt->data token) "role") ))
|
||||
{:redirect "/needs-activation"
|
||||
:db (assoc db/default-db
|
||||
:active-page :needs-activation
|
||||
:user token)}
|
||||
|
||||
:else
|
||||
{:db (assoc db/default-db
|
||||
:active-page handler
|
||||
:user token)
|
||||
|
||||
Reference in New Issue
Block a user