Skip to content

Commit 305a30d

Browse files
committed
combining phone auth and cleaning up old examples
1 parent 37e1818 commit 305a30d

File tree

9 files changed

+58
-186
lines changed

9 files changed

+58
-186
lines changed

config/documentNames.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
"eg017": "eg017SetTemplateTabValues.js",
2020
"eg018": "eg018EnvelopeCustomFieldData.js",
2121
"eg019": "eg019AccessCodeAuthentication.js",
22-
"eg020": "eg020SmsAuthentication.js",
23-
"eg021": "eg021PhoneAuthentication.js",
22+
"eg020": "eg020PhoneAuthentication.js",
2423
"eg022": "eg022KbaAuthentication.js",
2524
"eg023": "eg023IdvAuthentication.js",
2625
"eg024": "eg024CreateBrand.js",

index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const eg001 = require('./eg001EmbeddedSigning');
2424
const {
2525
eg002, eg003, eg004, eg005, eg006, eg007, eg008,
2626
eg009, eg010, eg011, eg012, eg013, eg014, eg015,
27-
eg016, eg017, eg018, eg019, eg020, eg021, eg022,
27+
eg016, eg017, eg018, eg019, eg020, eg022,
2828
eg023, eg024, eg025, eg026, eg027, eg028, eg029,
2929
eg030, eg031, eg032, eg033, eg034, eg035,
3030
} = require("./lib/eSignature/controllers");
@@ -186,8 +186,6 @@ if (dsConfig.examplesApi.isRoomsApi) {
186186
.post('/eg019', eg019.createController)
187187
.get('/eg020', eg020.getController)
188188
.post('/eg020', eg020.createController)
189-
.get('/eg021', eg021.getController)
190-
.post('/eg021', eg021.createController)
191189
.get('/eg022', eg022.getController)
192190
.post('/eg022', eg022.createController)
193191
.get('/eg023', eg023.getController)

lib/eSignature/controllers/eg021PhoneAuthentication.js renamed to lib/eSignature/controllers/eg020PhoneAuthentication.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @file
3-
* Example 021: Phone-based recipient authentication
3+
* Example 020: Phone authentication
44
* @author DocuSign
55
*/
66

@@ -9,8 +9,8 @@ const { phoneAuthentication } = require('../examples/phoneAuthentication');
99
const validator = require('validator');
1010
const dsConfig = require('../../../config/index.js').config;
1111

12-
const eg021PhoneAuthentication = exports;
13-
const eg = 'eg021'; // This example reference.
12+
const eg020PhoneAuthentication = exports;
13+
const eg = 'eg020'; // This example reference.
1414
const mustAuthenticate = '/ds/mustAuthenticate';
1515
const minimumBufferMin = 3;
1616

@@ -19,7 +19,7 @@ const minimumBufferMin = 3;
1919
* @param {object} req Request obj
2020
* @param {object} res Response obj
2121
*/
22-
eg021PhoneAuthentication.createController = async (req, res) => {
22+
eg020PhoneAuthentication.createController = async (req, res) => {
2323
// Step 1: Obtain your OAuth token
2424
// At this point we should have a good token. But we
2525
// double-check here to enable a better UX to the user.
@@ -36,7 +36,8 @@ eg021PhoneAuthentication.createController = async (req, res) => {
3636
const envelopeArgs = {
3737
signerEmail: validator.escape(body.signerEmail), // represents your {SIGNER_EMAIL}
3838
signerName: validator.escape(body.signerName), // represents your {SIGNER_NAME}
39-
phoneNumber: validator.escape(body.phoneNumber)
39+
phoneNumber: validator.escape(body.phoneNumber), // represents your phone number
40+
countryCode: validator.escape(body.countryCode) // represents your country code
4041
};
4142
const args = {
4243
accessToken: req.user.accessToken, // represents your {ACCESS_TOKEN}
@@ -47,9 +48,10 @@ eg021PhoneAuthentication.createController = async (req, res) => {
4748
let results = null;
4849

4950
try {
50-
// Step 2: Send the envelope
51+
// Step 2: Call the api method
5152
results = await phoneAuthentication(args);
52-
}
53+
console.log("WorkflowId: " + results.workflowId);
54+
}
5355
catch (error) {
5456
const errorBody = error && error.response && error.response.body;
5557
// we can pull the DocuSign error code and message from the response body
@@ -59,9 +61,10 @@ eg021PhoneAuthentication.createController = async (req, res) => {
5961
// remediation advice to the user.
6062
res.render('pages/error', {err: error, errorCode, errorMessage});
6163
}
64+
6265
if (results) {
6366
req.session.envelopeId = results.envelopeId; // Save for use by other examples
64-
// which need an envelopeId
67+
// which need an envelopeId
6568
res.render('pages/example_done', {
6669
title: "Envelope sent",
6770
h1: "Envelope sent",
@@ -70,18 +73,20 @@ eg021PhoneAuthentication.createController = async (req, res) => {
7073
}
7174
}
7275

76+
77+
7378
// ***DS.snippet.0.end
7479

7580
/**
7681
* Form page for this application
7782
*/
78-
eg021PhoneAuthentication.getController = (req, res) => {
83+
eg020PhoneAuthentication.getController = (req, res) => {
7984
// Check that the authentication token is ok with a long buffer time.
8085
// If needed, now is the best time to ask the user to authenticate
8186
// since they have not yet entered any information into the form.
8287
const tokenOK = req.dsAuth.checkToken();
8388
if (tokenOK) {
84-
res.render('pages/examples/eg021PhoneAuthentication', {
89+
res.render('pages/examples/eg020PhoneAuthentication', {
8590
eg: eg, csrfToken: req.csrfToken(),
8691
title: "Signing request by email",
8792
sourceFile: path.basename(__filename),
@@ -94,4 +99,4 @@ eg021PhoneAuthentication.getController = (req, res) => {
9499
req.dsAuth.setEg(req, eg);
95100
res.redirect(mustAuthenticate);
96101
}
97-
}
102+
}

lib/eSignature/controllers/eg020SmsAuthentication.js

Lines changed: 0 additions & 97 deletions
This file was deleted.

lib/eSignature/controllers/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ module.exports.eg016 = require('./eg016SetTabValues');
1717
module.exports.eg017 = require('./eg017SetTemplateTabValues');
1818
module.exports.eg018 = require('./eg018EnvelopeCustomFieldData');
1919
module.exports.eg019 = require('./eg019AccessCodeAuthentication');
20-
module.exports.eg020 = require('./eg020SmsAuthentication');
21-
module.exports.eg021 = require('./eg021PhoneAuthentication');
20+
module.exports.eg020 = require('./eg020PhoneAuthentication');
2221
module.exports.eg022 = require('./eg022KbaAuthentication');
2322
module.exports.eg023 = require('./eg023IdvAuthentication');
2423
module.exports.eg024 = require('./eg024CreatePermission');

lib/eSignature/examples/phoneAuthentication.js

Lines changed: 31 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

views/pages/examples/eg021PhoneAuthentication.ejs renamed to views/pages/examples/eg020PhoneAuthentication.ejs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<% include ../../partials/examplesHead %>
22

3-
<h4>21. Requiring an Phone Authentication for a Recipient</h4>
3+
<h4>20. Requiring an Phone Authentication for a Recipient</h4>
44
<p>
55
The envelope includes a pdf document. Anchor text
66
(<a href="https://developers.docusign.com/docs/esign-rest-api/esign101/concepts/tabs/auto-place/">AutoPlace</a>)
@@ -21,6 +21,11 @@
2121

2222
<% include ../../partials/gitSource %>
2323
<form class="eg" action="" method="post" data-busy="form">
24+
<div class="form-group">
25+
<label for="countryCode">Country Code</label>
26+
<input type="text" class="form-control" id="countryCode" placeholder="1" name="countryCode"
27+
value="1" required>
28+
</div>
2429
<div class="form-group">
2530
<label for="phoneNumber">Phone Number</label>
2631
<input type="text" class="form-control" id="phoneNumber" placeholder="415-555-1212" name="phoneNumber"

views/pages/examples/eg020SmsAuthentication.ejs

Lines changed: 0 additions & 40 deletions
This file was deleted.

views/pages/index_esignature_examples.ejs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,8 @@
175175
<a target='_blank' href="https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/envelopes/create/">Envelopes::create</a>.
176176
</p>
177177

178-
<h4 id="example020">20. <a href="eg020">SMS Authentication</a></h4>
179-
<p>This is an example of an envelope utilizing SMS authentication for multi-factor verification of a recipient.</p>
180-
<p>API method used:
181-
<a target='_blank' href="https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/envelopes/create/">Envelopes::create</a>.
182-
</p>
183-
184-
<h4 id="example021">21. <a href="eg021">Phone Authentication</a></h4>
185-
<p>This is an example of an envelope utilizing phone authentication for multi-factor verification of a
186-
recipient.</p>
178+
<h4 id="example020">20. <a href="eg020">Phone Recipient Authentication</a></h4>
179+
<p>This is an example of creating and sending an envelope (a signing request) using an SMS message or phone call for Recipient Authentication.</p>
187180
<p>API method used:
188181
<a target='_blank' href="https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/envelopes/create/">Envelopes::create</a>.
189182
</p>

0 commit comments

Comments
 (0)