one oauth approach.
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
[dk.ative/docjure "1.12.0"]
|
[dk.ative/docjure "1.12.0"]
|
||||||
[org.clojure/java.jdbc "0.7.3"]
|
[org.clojure/java.jdbc "0.7.3"]
|
||||||
[cljsjs/dropzone "4.3.0-0"]
|
[cljsjs/dropzone "4.3.0-0"]
|
||||||
|
[cljsjs/auth0-lock "10.24.1-0"]
|
||||||
[clj-fuzzy "0.4.1"]
|
[clj-fuzzy "0.4.1"]
|
||||||
;; https://mvnrepository.com/artifact/postgresql/postgresql
|
;; https://mvnrepository.com/artifact/postgresql/postgresql
|
||||||
[postgresql/postgresql "9.3-1102.jdbc41"]
|
[postgresql/postgresql "9.3-1102.jdbc41"]
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
(ns auto-ap.db)
|
(ns auto-ap.db)
|
||||||
|
|
||||||
(def default-db
|
(def default-db
|
||||||
{:company {:name "Campbell Brewing Company"}
|
{:user nil
|
||||||
|
:company {:name "Campbell Brewing Company"}
|
||||||
:companies [{:name "Campbell Brewing Company"
|
:companies [{:name "Campbell Brewing Company"
|
||||||
:matches ["campbell brewing company" "campbell brewery company" "campbell brewing"]}
|
:matches ["campbell brewing company" "campbell brewery company" "campbell brewing"]}
|
||||||
{:name "Brown Chicken Brown Cow"
|
{:name "Brown Chicken Brown Cow"
|
||||||
|
|||||||
@@ -16,6 +16,12 @@
|
|||||||
(fn [db [_ active-page]]
|
(fn [db [_ active-page]]
|
||||||
(update-in db [:menu :active?] #(not %))))
|
(update-in db [:menu :active?] #(not %))))
|
||||||
|
|
||||||
|
(re-frame/reg-event-db
|
||||||
|
::logged-in
|
||||||
|
(fn [db [_ token user]]
|
||||||
|
(doto (assoc db :user (assoc user :token token))
|
||||||
|
println)))
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::swap-company
|
::swap-company
|
||||||
(fn [db [_ company]]
|
(fn [db [_ company]]
|
||||||
|
|||||||
@@ -16,6 +16,11 @@
|
|||||||
(fn [db]
|
(fn [db]
|
||||||
(:menu db)))
|
(:menu db)))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
::user
|
||||||
|
(fn [db]
|
||||||
|
(:user db)))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
::active-page
|
::active-page
|
||||||
(fn [db]
|
(fn [db]
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
[auto-ap.events :as events]
|
[auto-ap.events :as events]
|
||||||
[cljs.reader :as edn]
|
[cljs.reader :as edn]
|
||||||
[cljsjs.dropzone :as dz]
|
[cljsjs.dropzone :as dz]
|
||||||
|
[cljsjs.auth0-lock :as a0]
|
||||||
[auto-ap.routes :as routes]
|
[auto-ap.routes :as routes]
|
||||||
[bidi.bidi :as bidi]
|
[bidi.bidi :as bidi]
|
||||||
[cljs-http.client :as http]
|
[cljs-http.client :as http]
|
||||||
@@ -217,6 +218,37 @@
|
|||||||
[:i.fa.fa-spin.fa-spinner])
|
[:i.fa.fa-spin.fa-spinner])
|
||||||
"Save"]]]]]))
|
"Save"]]]]]))
|
||||||
|
|
||||||
|
(def login
|
||||||
|
(let [lock (reagent/atom nil)
|
||||||
|
user (re-frame/subscribe [::subs/user])]
|
||||||
|
(with-meta (fn []
|
||||||
|
[:a {:class "navbar-link login" :on-click (fn [x e] (.preventDefault e) (.show @lock)) } (or (@user "name") "Login")])
|
||||||
|
{:component-did-mount (fn [this]
|
||||||
|
(let [l (js/Auth0Lock.
|
||||||
|
"twbXfoLvL0tKTR6GWORoM-ss51wM1zXZ",
|
||||||
|
"app82488100.auth0.com"
|
||||||
|
(clj->js {
|
||||||
|
:rememberLastLogin false,
|
||||||
|
:socialButtonStyle "big",
|
||||||
|
:oidcConformant true,
|
||||||
|
:auth {
|
||||||
|
:audience "https://app82488100.auth0.com/api/v2/",
|
||||||
|
:params {:scope "openid email profile"},
|
||||||
|
:responseType "token",
|
||||||
|
:redirect true,
|
||||||
|
:redirectUrl "http://localhost:3449"
|
||||||
|
}
|
||||||
|
:languageDictionary {:title "Auto AP"},
|
||||||
|
:language "en"
|
||||||
|
:theme {:primaryColor "#3A99D8"}
|
||||||
|
}))]
|
||||||
|
(.on l "authenticated" (fn [result]
|
||||||
|
(.getUserInfo l (.-accessToken result )
|
||||||
|
(fn [err profile]
|
||||||
|
(re-frame/dispatch [::events/logged-in (.-accessToken result) (js->clj profile)])))))
|
||||||
|
|
||||||
|
(reset! lock l)))})))
|
||||||
|
|
||||||
(defn main-panel []
|
(defn main-panel []
|
||||||
(let [company (re-frame/subscribe [::subs/company])
|
(let [company (re-frame/subscribe [::subs/company])
|
||||||
ap (re-frame/subscribe [::subs/active-page])
|
ap (re-frame/subscribe [::subs/active-page])
|
||||||
@@ -251,7 +283,7 @@
|
|||||||
[:div {:id "navMenu", :class "navbar-menu"}
|
[:div {:id "navMenu", :class "navbar-menu"}
|
||||||
[:div {:class "navbar-end"}
|
[:div {:class "navbar-end"}
|
||||||
[:div {:class "navbar-item has-dropdown is-active"}
|
[:div {:class "navbar-item has-dropdown is-active"}
|
||||||
[:a {:class "navbar-link login"} "Login"]
|
[login]
|
||||||
[:div {:class "navbar-dropdown", :style {:display "none"}}
|
[:div {:class "navbar-dropdown", :style {:display "none"}}
|
||||||
[:a {:class "navbar-item"} ]
|
[:a {:class "navbar-item"} ]
|
||||||
[:a {:class "navbar-item"} ]
|
[:a {:class "navbar-item"} ]
|
||||||
|
|||||||
Reference in New Issue
Block a user