Skip to content

Commit

Permalink
enhancement(TaxForms): bring back delegated links
Browse files Browse the repository at this point in the history
  • Loading branch information
Betree committed Jan 30, 2023
1 parent a5fe646 commit 62133fa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
27 changes: 14 additions & 13 deletions server/lib/tax-forms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export async function sendHelloWorksUsTaxForm(
workflowId,
documentDelivery: true,
documentDeliveryType: 'link',
// delegatedAuthentication: true, // See "authenticated link" below.
delegatedAuthentication: true, // See "authenticated link" below.
participants,
metadata: {
accountType: accountToSubmitRequestTo.type,
Expand All @@ -157,20 +157,21 @@ export async function sendHelloWorksUsTaxForm(
});

// Get the authenticated link ("delegated authentication")
// We currently don't have access to this feature with our pricing plan
// try {
// documentLink = await client.workflowInstances.getAuthenticatedLinkForStep({
// instanceId: instance.id,
// step: step.step,
// });
// } catch (e) {
// // Fallback to the default `step.url` (unauthenticated link)
// logger.warn(`Tax form: error getting authenticated link for ${instance.id}: ${e.message}`);
// }
const step = instance.steps[0];
let documentLink = step.url;
try {
documentLink = await client.workflowInstances.getAuthenticatedLinkForStep({
instanceId: instance.id,
step: step.step,
});
} catch (e) {
// Fallback to the default `step.url` (unauthenticated link)
reportMessageToSentry('Tax form: error getting authenticated link', {
extra: { error: JSON.stringify(e), instanceId: instance.id },
});
}

// Save the authenticated link to the database, in case we want to send it again later
const step = instance.steps[0];
const documentLink = step.url;
await document.update({ data: deepMerge(document.data, { helloWorks: { documentLink } }) });

// Send the actual email
Expand Down
2 changes: 1 addition & 1 deletion test/server/lib/tax-forms.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ describe('server/lib/tax-forms', () => {
expect(client.workflowInstances.createInstance.called).to.be.true;
const callArgs = client.workflowInstances.createInstance.firstCall.args;
expect(callArgs[0].participants['participant_swVuvW'].fullName).to.eq('Mr. Legal Name');
// when we'll activate authenticated links expect(client.workflowInstances.getAuthenticatedLinkForStep.called).to.be.true;
expect(client.workflowInstances.getAuthenticatedLinkForStep.called).to.be.true;
expect(doc.requestStatus).to.eq(REQUESTED);

assert.callCount(sendMessageSpy, 1);
Expand Down

0 comments on commit 62133fa

Please sign in to comment.