new approach for oauth

This commit is contained in:
Bryce Covert
2017-12-18 21:44:21 -08:00
parent 129a92c688
commit 3b3295f535
3 changed files with 32 additions and 32 deletions

View File

@@ -6,7 +6,6 @@
[auto-ap.events :as events]
[cljs.reader :as edn]
[cljsjs.dropzone :as dz]
[cljsjs.auth0-lock :as a0]
[auto-ap.routes :as routes]
[bidi.bidi :as bidi]
[cljs-http.client :as http]
@@ -218,36 +217,14 @@
[:i.fa.fa-spin.fa-spinner])
"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 login-url []
(let [client-id "264081895820-0nndcfo3pbtqf30sro82vgq5r27h8736.apps.googleusercontent.com"
redirect-uri "http%3A%2F%2Flocalhost%3A3449%2Fapi%2Foauth"]
(str "https://accounts.google.com/o/oauth2/auth?access_type=online&client_id=" client-id "&redirect_uri=" redirect-uri "&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile"))
)
(defn login []
(let [user (re-frame/subscribe [::subs/user])]
[:a {:class "navbar-link login" :href (login-url)} (or (get @user "name") "Login")]))
(defn main-panel []
(let [company (re-frame/subscribe [::subs/company])