mirror of
https://github.com/we-promise/sure.git
synced 2026-05-30 15:59:02 +00:00
* fix(plaid): surface configuration/product-access errors from Link flow (#1792) * fix(plaid): harden Plaid Link onExit guard + nil-body JSON parse (#1792 review) * fix lint check issue * fix test unit check
This commit is contained in:
committed by
Juan José Mata
parent
4acf3ea581
commit
fb50963794
@@ -128,9 +128,32 @@ export default class extends Controller {
|
||||
};
|
||||
|
||||
handleExit = (err, metadata) => {
|
||||
// If there was an error during update mode, refresh the page to show latest status
|
||||
if (err && metadata.status === "requires_credentials") {
|
||||
// If there was an error during update mode, refresh the page to show
|
||||
// latest status. Guard `metadata` (Plaid can fire onExit with it
|
||||
// undefined when Link aborts very early) and gate the redirect on
|
||||
// `isUpdateValue` so first-time link failures don't bounce the user
|
||||
// away from whatever page they were on.
|
||||
if (
|
||||
err &&
|
||||
metadata &&
|
||||
metadata.status === "requires_credentials" &&
|
||||
this.isUpdateValue
|
||||
) {
|
||||
window.location.href = "/accounts";
|
||||
return;
|
||||
}
|
||||
|
||||
// Promote Plaid's own error payload to the console so a silent modal
|
||||
// close still leaves a breadcrumb (issue #1792). Plaid Link's own UI
|
||||
// is responsible for showing a message inside the modal when this
|
||||
// fires; backend link-token failures are handled server-side via the
|
||||
// PlaidItemsController rescue + flash.
|
||||
if (err?.error_code) {
|
||||
console.error(
|
||||
"Plaid Link exited with error",
|
||||
err.error_code,
|
||||
err.display_message || err.error_message
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user