working on reauth.

This commit is contained in:
2022-03-29 19:50:13 -07:00
parent 17fde0dd16
commit 17e6b283df
4 changed files with 135 additions and 18 deletions

View File

@@ -54,5 +54,24 @@
{:status 400
:headers {"Content-Type" "application/edn"}
:body (pr-str {:message (.getMessage e)
:error (.toString e)})})))
(POST "/reauthenticate/:id" {:keys [identity] {:keys [id]} :route-params
data :edn-params}
(assert-admin identity)
(try
{:status 200
:headers {"Content-Type" "application/edn"}
:body (pr-str (yodlee/reauthenticate-and-recache
(-> (:client-id data)
Long/parseLong
d-clients/get-by-id
:client/code)
(Long/parseLong id)
(dissoc data :client-id )))}
(catch Exception e
(log/error e)
{:status 500
:headers {"Content-Type" "application/edn"}
:body (pr-str {:message (.getMessage e)
:error (.toString e)})}))))
wrap-secure))

View File

@@ -330,17 +330,20 @@
(update-provider-account id)
(refresh-provider-account id))
(defn reauthenticate [pa data]
(let [cob-session (login-cobrand)]
(try
(doto (-> (str (:yodlee2-base-url env) "/providerAccounts?providerAccountIds=" pa)
(defn reauthenticate [client-code pa data]
(println client-code)
(try
(doto (-> (str (:yodlee2-base-url env) "/providerAccounts?providerAccountIds=" pa)
(client/put (merge {:headers (merge base-headers {"Authorization" (auth-header cob-session)})
:body (json/write-str data)
:as :json}
other-config)))
log/info)
(refresh-provider-account pa)
(catch Exception e
(log/error e)))))
(client/put (doto (merge {:headers (merge base-headers {"Authorization" (auth-header (login-user (client-code->login client-code)))})
:body (json/write-str data)
:as :json}
other-config)
clojure.pprint/pprint)))
log/info)
(catch Exception e
(log/error e))) )
(defn reauthenticate-and-recache [client-code pa data]
(reauthenticate client-code pa data)
(refresh-provider-account client-code pa))