adds plaid reauth
This commit is contained in:
@@ -26,6 +26,22 @@
|
|||||||
:body
|
:body
|
||||||
:link_token))
|
: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 _]
|
(defn exchange-public-token [public-token _]
|
||||||
(-> (client/post (str base-url "/item/public_token/exchange")
|
(-> (client/post (str base-url "/item/public_token/exchange")
|
||||||
{:as :json
|
{:as :json
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
[auto-ap.ssr.components :as com]
|
[auto-ap.ssr.components :as com]
|
||||||
[auto-ap.ssr.grid-page-helper :as helper]
|
[auto-ap.ssr.grid-page-helper :as helper]
|
||||||
[auto-ap.ssr.svg :as svg]
|
[auto-ap.ssr.svg :as svg]
|
||||||
|
[auto-ap.ssr.utils :refer [html-response]]
|
||||||
[auto-ap.time :as atime]
|
[auto-ap.time :as atime]
|
||||||
[bidi.bidi :as bidi]
|
[bidi.bidi :as bidi]
|
||||||
[clj-time.coerce :as coerce]
|
[clj-time.coerce :as coerce]
|
||||||
@@ -25,6 +26,7 @@
|
|||||||
|
|
||||||
(def default-read '[:db/id
|
(def default-read '[:db/id
|
||||||
:plaid-item/external-id
|
:plaid-item/external-id
|
||||||
|
:plaid-item/access-token
|
||||||
:plaid-item/last-updated
|
:plaid-item/last-updated
|
||||||
:plaid-item/status
|
:plaid-item/status
|
||||||
{:plaid-item/accounts [:db/id
|
{:plaid-item/accounts [:db/id
|
||||||
@@ -116,6 +118,25 @@
|
|||||||
{:headers {"Hx-redirect" (bidi/path-for ssr-routes/only-routes
|
{:headers {"Hx-redirect" (bidi/path-for ssr-routes/only-routes
|
||||||
:company-plaid)}}))
|
: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"
|
(def grid-page {:id "plaid-table"
|
||||||
:nav (com/company-aside-nav)
|
:nav (com/company-aside-nav)
|
||||||
@@ -146,12 +167,12 @@
|
|||||||
(com/button-icon {} svg/refresh)
|
(com/button-icon {} svg/refresh)
|
||||||
"Link new account")]]))
|
"Link new account")]]))
|
||||||
:row-buttons (fn [user e]
|
:row-buttons (fn [user e]
|
||||||
[]
|
[[:div (com/button {:hx-put (str (bidi/path-for ssr-routes/only-routes
|
||||||
#_[(when (is-admin? user)
|
:company-plaid-relink)
|
||||||
(com/icon-button {:hx-put (bidi/path-for ssr-routes/only-routes
|
"?plaid-item-id=" (:db/id e))
|
||||||
:company-yodlee-provider-account-refresh)
|
:color :primary
|
||||||
:hx-target "closest tr"}
|
:hx-target "closest div"}
|
||||||
svg/refresh))])
|
"Reauthenticate")]])
|
||||||
:headers [{:key "plaid-item"
|
:headers [{:key "plaid-item"
|
||||||
:name "Plaid Item"
|
:name "Plaid Item"
|
||||||
:sort-key "id"
|
:sort-key "id"
|
||||||
@@ -159,11 +180,11 @@
|
|||||||
{:key "status"
|
{:key "status"
|
||||||
:name "Status"
|
:name "Status"
|
||||||
:sort-key "status"
|
:sort-key "status"
|
||||||
:render #(when-let [status (:plaid-item/status %)]
|
:render #(when-let [status (:plaid-item/status %)]
|
||||||
[:div [:div (com/pill {:color :primary }
|
[:div [:div (com/pill {:color :primary}
|
||||||
status)]
|
status)]
|
||||||
[:div (atime/unparse-local (coerce/to-date-time (:plaid-item/last-updated %)) atime/normal-date)]])}
|
[:div (atime/unparse-local (coerce/to-date-time (:plaid-item/last-updated %)) atime/normal-date)]])}
|
||||||
|
|
||||||
{:key "accounts"
|
{:key "accounts"
|
||||||
:name "Accounts"
|
:name "Accounts"
|
||||||
:show-starting "md"
|
:show-starting "md"
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
:company-plaid (wrap-client-redirect-unauthenticated (wrap-secure company-plaid/page))
|
: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-table (wrap-client-redirect-unauthenticated (wrap-secure company-plaid/table))
|
||||||
:company-plaid-link (wrap-client-redirect-unauthenticated (wrap-secure company-plaid/link))
|
: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 (wrap-client-redirect-unauthenticated (wrap-secure company-yodlee/page))
|
||||||
:company-yodlee-table (wrap-client-redirect-unauthenticated (wrap-secure company-yodlee/table))
|
: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))
|
:company-yodlee-fastlink-dialog (wrap-client-redirect-unauthenticated (wrap-secure company-yodlee/fastlink-dialog))
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
"/plaid" {"" {:get :company-plaid}
|
"/plaid" {"" {:get :company-plaid}
|
||||||
"/table" {:get :company-plaid-table}
|
"/table" {:get :company-plaid-table}
|
||||||
"/link" {:post :company-plaid-link}
|
"/link" {:post :company-plaid-link}
|
||||||
|
"/relink" {:put :company-plaid-relink}
|
||||||
#_#_"/fastlink" {:get :company-yodlee-fastlink-dialog}
|
#_#_"/fastlink" {:get :company-yodlee-fastlink-dialog}
|
||||||
#_#_"/refresh" {:put :company-yodlee-provider-account-refresh}}}})
|
#_#_"/refresh" {:put :company-yodlee-provider-account-refresh}}}})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user