adds plaid reauth
This commit is contained in:
@@ -26,6 +26,22 @@
|
||||
:body
|
||||
:link_token))
|
||||
|
||||
(defn get-relink-token [client-code access-token]
|
||||
(-> (client/post (str base-url "/link/token/create")
|
||||
{:as :json
|
||||
:headers {"Content-Type" "application/json"}
|
||||
:body (json/write-str {"client_id" client-id
|
||||
"secret" secret-key
|
||||
"client_name" "Integreat Consulting"
|
||||
"access_token" access-token
|
||||
"country_codes" ["US"]
|
||||
"language" "en"
|
||||
"user" {"client_user_id" client-code}})})
|
||||
:body
|
||||
:link_token))
|
||||
|
||||
|
||||
|
||||
(defn exchange-public-token [public-token _]
|
||||
(-> (client/post (str base-url "/item/public_token/exchange")
|
||||
{:as :json
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
[auto-ap.ssr.components :as com]
|
||||
[auto-ap.ssr.grid-page-helper :as helper]
|
||||
[auto-ap.ssr.svg :as svg]
|
||||
[auto-ap.ssr.utils :refer [html-response]]
|
||||
[auto-ap.time :as atime]
|
||||
[bidi.bidi :as bidi]
|
||||
[clj-time.coerce :as coerce]
|
||||
@@ -25,6 +26,7 @@
|
||||
|
||||
(def default-read '[:db/id
|
||||
:plaid-item/external-id
|
||||
:plaid-item/access-token
|
||||
:plaid-item/last-updated
|
||||
:plaid-item/status
|
||||
{:plaid-item/accounts [:db/id
|
||||
@@ -116,6 +118,25 @@
|
||||
{:headers {"Hx-redirect" (bidi/path-for ssr-routes/only-routes
|
||||
:company-plaid)}}))
|
||||
|
||||
(defn relink [{{:strs [plaid-item-id]} :query-params :keys [identity]}]
|
||||
|
||||
(let [pi (dc/pull (dc/db conn)
|
||||
[:plaid-item/access-token {:plaid-item/client [:client/code]}]
|
||||
(Long/parseLong plaid-item-id))]
|
||||
(assert-can-see-client identity (pull-attr (dc/db conn) :db/id [:client/code (-> pi :plaid-item/client
|
||||
:client/code)]))
|
||||
(html-response
|
||||
[:div
|
||||
[:script (hiccup/raw (plaid-link-script (p/get-relink-token (-> pi :plaid-item/client
|
||||
:client/code)
|
||||
(-> pi :plaid-item/access-token))))]
|
||||
[:script (hiccup/raw "window.plaid.open()")]
|
||||
#_(com/button {:color :primary
|
||||
:id "link-account"
|
||||
:onClick "window.plaid.open()"}
|
||||
(com/button-icon {} svg/refresh)
|
||||
"Start relink")])))
|
||||
|
||||
|
||||
(def grid-page {:id "plaid-table"
|
||||
:nav (com/company-aside-nav)
|
||||
@@ -146,12 +167,12 @@
|
||||
(com/button-icon {} svg/refresh)
|
||||
"Link new account")]]))
|
||||
:row-buttons (fn [user e]
|
||||
[]
|
||||
#_[(when (is-admin? user)
|
||||
(com/icon-button {:hx-put (bidi/path-for ssr-routes/only-routes
|
||||
:company-yodlee-provider-account-refresh)
|
||||
:hx-target "closest tr"}
|
||||
svg/refresh))])
|
||||
[[:div (com/button {:hx-put (str (bidi/path-for ssr-routes/only-routes
|
||||
:company-plaid-relink)
|
||||
"?plaid-item-id=" (:db/id e))
|
||||
:color :primary
|
||||
:hx-target "closest div"}
|
||||
"Reauthenticate")]])
|
||||
:headers [{:key "plaid-item"
|
||||
:name "Plaid Item"
|
||||
:sort-key "id"
|
||||
@@ -159,11 +180,11 @@
|
||||
{:key "status"
|
||||
:name "Status"
|
||||
:sort-key "status"
|
||||
:render #(when-let [status (:plaid-item/status %)]
|
||||
[:div [:div (com/pill {:color :primary }
|
||||
:render #(when-let [status (:plaid-item/status %)]
|
||||
[:div [:div (com/pill {:color :primary}
|
||||
status)]
|
||||
[:div (atime/unparse-local (coerce/to-date-time (:plaid-item/last-updated %)) atime/normal-date)]])}
|
||||
|
||||
|
||||
{:key "accounts"
|
||||
:name "Accounts"
|
||||
:show-starting "md"
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
:company-plaid (wrap-client-redirect-unauthenticated (wrap-secure company-plaid/page))
|
||||
:company-plaid-table (wrap-client-redirect-unauthenticated (wrap-secure company-plaid/table))
|
||||
:company-plaid-link (wrap-client-redirect-unauthenticated (wrap-secure company-plaid/link))
|
||||
:company-plaid-relink (wrap-client-redirect-unauthenticated (wrap-secure company-plaid/relink))
|
||||
:company-yodlee (wrap-client-redirect-unauthenticated (wrap-secure company-yodlee/page))
|
||||
:company-yodlee-table (wrap-client-redirect-unauthenticated (wrap-secure company-yodlee/table))
|
||||
:company-yodlee-fastlink-dialog (wrap-client-redirect-unauthenticated (wrap-secure company-yodlee/fastlink-dialog))
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
"/plaid" {"" {:get :company-plaid}
|
||||
"/table" {:get :company-plaid-table}
|
||||
"/link" {:post :company-plaid-link}
|
||||
"/relink" {:put :company-plaid-relink}
|
||||
#_#_"/fastlink" {:get :company-yodlee-fastlink-dialog}
|
||||
#_#_"/refresh" {:put :company-yodlee-provider-account-refresh}}}})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user