merged.
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
|
||||
(defroutes routes
|
||||
(GET "/oauth" {{:strs [code]} :query-params :keys [scheme] :as r {:strs [host]} :headers}
|
||||
(println "Authenticating with" r "..." code)
|
||||
(try
|
||||
(let [auth (-> "https://accounts.google.com/o/oauth2/token"
|
||||
(http/post
|
||||
@@ -44,17 +45,19 @@
|
||||
|
||||
;; TODO - these namespaces are not being transmitted/deserialized properly
|
||||
(if (and token user)
|
||||
{:status 301
|
||||
:headers {"Location" (str "/?jwt=" (jwt/sign (doto {:user (:name profile)
|
||||
:exp (time/plus (time/now) (time/days 30))
|
||||
:user/clients (map (fn [c]
|
||||
(dissoc c :client/bank-accounts ))
|
||||
(:user/clients user))
|
||||
:user/role (name (:user/role user))
|
||||
:user/name (:name profile)}
|
||||
println)
|
||||
(:jwt-secret env)
|
||||
{:alg :hs512}))}}
|
||||
(let [jwt (jwt/sign (doto {:user (:name profile)
|
||||
:exp (time/plus (time/now) (time/days 30))
|
||||
:user/clients (map (fn [c]
|
||||
(dissoc c :client/bank-accounts :client/location-matches))
|
||||
(:user/clients user))
|
||||
:user/role (name (:user/role user))
|
||||
:user/name (:name profile)}
|
||||
println)
|
||||
(:jwt-secret env)
|
||||
{:alg :hs512})]
|
||||
(println "authenticated. using jwt" jwt)
|
||||
{:status 301
|
||||
:headers {"Location" (str "/?jwt=" jwt)}})
|
||||
{:status 401
|
||||
:body "Couldn't authenticate"}))
|
||||
(catch Exception e
|
||||
|
||||
@@ -166,7 +166,6 @@
|
||||
|
||||
(defn import-uploaded-invoice [imports]
|
||||
(let [clients (d-clients/get-all)
|
||||
_ (clojure.pprint/pprint imports)
|
||||
|
||||
transactions (reduce (fn [result {:keys [invoice-number customer-identifier total date vendor-code text full-text] :as info}]
|
||||
(println "searching for" vendor-code)
|
||||
@@ -204,6 +203,7 @@
|
||||
|
||||
:else
|
||||
(conj result (remove-nils #:invoice {:invoice/client (:db/id matching-client)
|
||||
:invoice/client-identifier customer-identifier
|
||||
:invoice/vendor matching-vendor
|
||||
:invoice/invoice-number invoice-number
|
||||
:invoice/total (Double/parseDouble total)
|
||||
@@ -219,8 +219,7 @@
|
||||
))
|
||||
[]
|
||||
imports)]
|
||||
|
||||
@(d/transact (d/connect uri) transactions)))
|
||||
@(d/transact (d/connect uri) (vec (set transactions)))))
|
||||
|
||||
(defroutes routes
|
||||
(wrap-routes
|
||||
|
||||
Reference in New Issue
Block a user