auth now actually works straight through google

This commit is contained in:
Bryce Covert
2017-12-18 22:45:24 -08:00
parent 3b3295f535
commit 36806c9cf6
6 changed files with 57 additions and 14 deletions

View File

@@ -27,6 +27,9 @@
(defn ^:export init []
(dev-setup)
(when-let [jwt (.get (js/URLSearchParams. (.-search (.-location js/window))) "jwt")]
(println "got jwt" jwt)
(.setItem js/localStorage "jwt" jwt))
(pushy/start! (pushy/pushy dispatch-route parse-url))
(re-frame/dispatch-sync [::events/initialize-db])
(mount-root))

View File

@@ -1,7 +1,7 @@
(ns auto-ap.db)
(def default-db
{:user nil
{:user (.getItem js/localStorage "jwt")
:company {:name "Campbell Brewing Company"}
:companies [{:name "Campbell Brewing Company"
:matches ["campbell brewing company" "campbell brewery company" "campbell brewing"]}

View File

@@ -1,5 +1,7 @@
(ns auto-ap.subs
(:require [re-frame.core :as re-frame]))
(:require [re-frame.core :as re-frame]
[clojure.string :as str]
[goog.crypt.base64 :as base64]))
(re-frame/reg-sub
::company
@@ -19,7 +21,10 @@
(re-frame/reg-sub
::user
(fn [db]
(:user db)))
(when (:user db)
(let [{:strs [name] :as x} (js->clj (.parse js/JSON (base64/decodeString (second (str/split (:user db) #"\.")))))]
(println x)
{:name name}))))
(re-frame/reg-sub
::active-page

View File

@@ -224,7 +224,8 @@
)
(defn login []
(let [user (re-frame/subscribe [::subs/user])]
[:a {:class "navbar-link login" :href (login-url)} (or (get @user "name") "Login")]))
(println @user)
[:a {:class "navbar-link login" :href (login-url)} (or (:name @user) "Login")]))
(defn main-panel []
(let [company (re-frame/subscribe [::subs/company])