Tweak for poke
This commit is contained in:
@@ -27,6 +27,7 @@
|
|||||||
[clj-time.coerce :as coerce]
|
[clj-time.coerce :as coerce]
|
||||||
[clj-time.core :as t]
|
[clj-time.core :as t]
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
|
[config.core :refer [env]]
|
||||||
[clojure.tools.logging :as log]
|
[clojure.tools.logging :as log]
|
||||||
[clojure.walk :as walk]
|
[clojure.walk :as walk]
|
||||||
[com.brunobonacci.mulog :as mu]
|
[com.brunobonacci.mulog :as mu]
|
||||||
@@ -37,7 +38,8 @@
|
|||||||
[datomic.api :as dc]
|
[datomic.api :as dc]
|
||||||
[unilog.context :as lc]
|
[unilog.context :as lc]
|
||||||
[yang.time :refer [time-it]]
|
[yang.time :refer [time-it]]
|
||||||
[auto-ap.routes.auth :as auth])
|
[auto-ap.routes.auth :as auth]
|
||||||
|
[buddy.sign.jwt :as jwt])
|
||||||
(:import
|
(:import
|
||||||
(clojure.lang IPersistentMap)))
|
(clojure.lang IPersistentMap)))
|
||||||
|
|
||||||
@@ -627,7 +629,9 @@
|
|||||||
(let [users (->> (d-users/get-graphql args)
|
(let [users (->> (d-users/get-graphql args)
|
||||||
(map (fn [u]
|
(map (fn [u]
|
||||||
(assoc u :impersonate_jwt
|
(assoc u :impersonate_jwt
|
||||||
(auth/user->jwt u "FAKE_TOKEN")))))]
|
(jwt/sign (auth/user->jwt u "FAKE_TOKEN")
|
||||||
|
(:jwt-secret env)
|
||||||
|
{:alg :hs512})))))]
|
||||||
(->graphql users)))
|
(->graphql users)))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -217,6 +217,7 @@
|
|||||||
seq
|
seq
|
||||||
(pull-many (dc/db conn)
|
(pull-many (dc/db conn)
|
||||||
d-clients/full-read))]
|
d-clients/full-read))]
|
||||||
|
|
||||||
(lc/with-context {:clients (map :client/code clients)}
|
(lc/with-context {:clients (map :client/code clients)}
|
||||||
(handler (assoc request
|
(handler (assoc request
|
||||||
:clients clients
|
:clients clients
|
||||||
@@ -233,7 +234,9 @@
|
|||||||
(do
|
(do
|
||||||
(assert-can-see-client identity (cond-> client-id
|
(assert-can-see-client identity (cond-> client-id
|
||||||
(string? client-id) (Long/parseLong)))
|
(string? client-id) (Long/parseLong)))
|
||||||
[client-id])
|
[(if (string? client-id)
|
||||||
|
(Long/parseLong client-id)
|
||||||
|
client-id)])
|
||||||
x-clients)
|
x-clients)
|
||||||
(catch Exception e
|
(catch Exception e
|
||||||
(alog/warn ::cant-access :error e
|
(alog/warn ::cant-access :error e
|
||||||
|
|||||||
@@ -62,9 +62,7 @@
|
|||||||
(select-keys c [:client/code :db/id :client/locations]))))))]
|
(select-keys c [:client/code :db/id :client/locations]))))))]
|
||||||
|
|
||||||
(when (and user oauth-token)
|
(when (and user oauth-token)
|
||||||
(jwt/sign auth
|
auth)))
|
||||||
(:jwt-secret env)
|
|
||||||
{:alg :hs512}))))
|
|
||||||
|
|
||||||
(defn oauth [{{:strs [code state]} :query-params {:strs [host]} :headers :as request}]
|
(defn oauth [{{:strs [code state]} :query-params {:strs [host]} :headers :as request}]
|
||||||
(try
|
(try
|
||||||
@@ -93,8 +91,11 @@
|
|||||||
|
|
||||||
(if-let [jwt (user->jwt user token)]
|
(if-let [jwt (user->jwt user token)]
|
||||||
{:status 301
|
{:status 301
|
||||||
:headers {"Location" (str (or (not-empty state) "/") "?jwt=" jwt)}
|
:headers {"Location" (str (or (not-empty state) "/") "?jwt="
|
||||||
:session {:identity (dissoc auth :exp)}}
|
(jwt/sign jwt
|
||||||
|
(:jwt-secret env)
|
||||||
|
{:alg :hs512}))}
|
||||||
|
:session {:identity (dissoc jwt :exp)}}
|
||||||
{:status 401
|
{:status 401
|
||||||
:body "Couldn't authenticate"}))
|
:body "Couldn't authenticate"}))
|
||||||
(catch Exception e
|
(catch Exception e
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
(let [variables (some-> (query-params "variables")
|
(let [variables (some-> (query-params "variables")
|
||||||
edn/read-string)
|
edn/read-string)
|
||||||
body (some-> r :body slurp)]
|
body (some-> r :body slurp)]
|
||||||
|
(println "CLIENTS" clients)
|
||||||
|
|
||||||
{:status 200
|
{:status 200
|
||||||
:body (pr-str (ql/query (:identity r) (if (= request-method :get) (query-params "query") body) (assoc variables
|
:body (pr-str (ql/query (:identity r) (if (= request-method :get) (query-params "query") body) (assoc variables
|
||||||
|
|||||||
Reference in New Issue
Block a user