Should fix most of the authentication issues
This commit is contained in:
@@ -56,6 +56,11 @@
|
||||
(when (= "admin" (:user/role @user))
|
||||
[:a {:class "navbar-item" :href (bidi/path-for routes/routes :admin)} "Administration"])
|
||||
[:hr {:class "navbar-divider"}]
|
||||
[:a.navbar-item {:on-click (fn []
|
||||
(.removeItem js/localStorage "last-client-id" nil)
|
||||
(.setItem js/localStorage "last-selected-clients" ":all")
|
||||
(.reload (.-location js/document ) true))}
|
||||
"Full Refresh"]
|
||||
[:a.navbar-item {:on-click (fn [e] (.preventDefault e) (re-frame/dispatch [::events/logout]))} "Logout"]]]
|
||||
[:a.navbar-item {:href (login-url)} "Login"])))
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
[:name
|
||||
:profile_image_url
|
||||
:email
|
||||
:impersonate_jwt
|
||||
:id
|
||||
:role
|
||||
[:clients [:id :name]]]]]}
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
[grid/header-cell {} "Email"]
|
||||
[grid/header-cell {} "Role"]
|
||||
[grid/header-cell {} "Clients"]
|
||||
[grid/header-cell {:style {:width (action-cell-width 1)}}]]]
|
||||
[grid/header-cell {:style {:width (action-cell-width 5)}}]]]
|
||||
[grid/body
|
||||
(for [{:keys [id name role clients] :as c} (:data page)]
|
||||
^{:key (str name "-" id)}
|
||||
@@ -50,6 +50,14 @@
|
||||
[grid/cell {} role]
|
||||
[grid/cell {} (str/join ", " (map :name clients))]
|
||||
[grid/cell {}
|
||||
[:a.button {:on-click (fn []
|
||||
(.setItem js/localStorage "jwt" (:impersonate-jwt c))
|
||||
(.removeItem js/localStorage "last-client-id" nil)
|
||||
(.removeItem js/localStorage "last-selected-clients" nil)
|
||||
(.reload (.-location js/document ) true))}
|
||||
"Impersonate"]
|
||||
|
||||
|
||||
[buttons/fa-icon {:event [::form/editing c]
|
||||
:icon "fa-pencil"}]]])]]
|
||||
]))
|
||||
|
||||
@@ -8,10 +8,14 @@
|
||||
[:div.column.is-8.is-offset-2.has-text-centered
|
||||
|
||||
[:div.box.slideInFromBelow
|
||||
[:img {:src "http://www.integreatconsult.com/wp-content/uploads/2016/11/logo.png"}]
|
||||
[:img {:src "/img/logo.png"}]
|
||||
[:div.notification.is-danger.is-light "An unexpected error has occured. "
|
||||
[:a {:on-click #(.reload (.-location js/document )) } "Click here"]
|
||||
" to try again."]]
|
||||
[:div [:a {:on-click (fn []
|
||||
(.removeItem js/localStorage "last-client-id" nil)
|
||||
(.removeItem js/localStorage "last-selected-clients" nil)
|
||||
(.reload (.-location js/document ) true)) } "Click here"]
|
||||
" to try again."]
|
||||
[:div "If the error continues, please try " [:a {:href "/login"} "logging in"] " again."]]]
|
||||
[:p.has-text-gray
|
||||
"Copyright Integreat 2020"]]]]]]
|
||||
)
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
[react-transition-group :as react-transition-group]
|
||||
#_{:clj-kondo/ignore [:unused-namespace]}
|
||||
[react :as react]
|
||||
[reagent.core :as r])
|
||||
[reagent.core :as r]
|
||||
[pako])
|
||||
(:import
|
||||
(goog.i18n NumberFormat)
|
||||
(goog.i18n.NumberFormat Format)))
|
||||
@@ -297,13 +298,25 @@
|
||||
:else
|
||||
x))
|
||||
|
||||
(defn gunzip [b64]
|
||||
(let [raw-byte-array (->> b64
|
||||
js/atob
|
||||
(map (fn [z] (.charCodeAt z 0)))
|
||||
clj->js
|
||||
(js/Uint8Array.))]
|
||||
(or (edn/read-string (pako/inflate raw-byte-array #js {"to" "string"}))
|
||||
nil)))
|
||||
|
||||
(defn parse-jwt [jwt]
|
||||
(when-let [json (some-> jwt
|
||||
(str/split #"\.")
|
||||
second
|
||||
base64/decodeString)]
|
||||
(js->clj (.parse js/JSON json) :keywordize-keys true)))
|
||||
(let [raw (js->clj (.parse js/JSON json) :keywordize-keys true)
|
||||
gz-clients (or (:gz-clients raw)
|
||||
(get raw "gz-clients"))]
|
||||
(cond-> raw
|
||||
gz-clients (assoc :user/clients (gunzip gz-clients))))))
|
||||
|
||||
(defn coerce-float [f]
|
||||
(cond (str/blank? f)
|
||||
|
||||
Reference in New Issue
Block a user