Skip to content

Commit 9089515

Browse files
committed
merging phone auth changes
2 parents 699642f + c5ecfac commit 9089515

File tree

10 files changed

+98
-218
lines changed

10 files changed

+98
-218
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");
@@ -187,8 +187,6 @@ if (dsConfig.examplesApi.isRoomsApi) {
187187
.post('/eg019', eg019.createController)
188188
.get('/eg020', eg020.getController)
189189
.post('/eg020', eg020.createController)
190-
.get('/eg021', eg021.getController)
191-
.post('/eg021', eg021.createController)
192190
.get('/eg022', eg022.getController)
193191
.post('/eg022', eg022.createController)
194192
.get('/eg023', eg023.getController)

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

Lines changed: 21 additions & 17 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,34 +61,36 @@ 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', {
66-
title: "Envelope sent",
67-
h1: "Envelope sent",
69+
title: "Require Phone Authentication for a Recipient",
70+
h1: "Require Phone Authentication for a Recipient",
6871
message: `The envelope has been created and sent!<br/>Envelope ID ${results.envelopeId}.`
6972
});
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-
sourceFile = (path.basename(__filename))[5].toLowerCase() + (path.basename(__filename)).substr(6);
85-
res.render('pages/examples/eg021PhoneAuthentication', {
89+
res.render('pages/examples/eg020PhoneAuthentication', {
8690
eg: eg, csrfToken: req.csrfToken(),
87-
title: "Signing request by email",
88-
sourceFile: sourceFile,
89-
sourceUrl: dsConfig.githubExampleUrl + 'eSignature/examples/' + sourceFile,
91+
title: "Require Phone Authentication for a Recipient",
92+
sourceFile: path.basename(__filename),
93+
sourceUrl: dsConfig.githubExampleUrl + 'eSignature/' + path.basename(__filename),
9094
documentation: dsConfig.documentation + eg,
9195
showDoc: dsConfig.documentation
9296
});
@@ -95,4 +99,4 @@ eg021PhoneAuthentication.getController = (req, res) => {
9599
req.dsAuth.setEg(req, eg);
96100
res.redirect(mustAuthenticate);
97101
}
98-
}
102+
}

lib/eSignature/controllers/eg020SmsAuthentication.js

Lines changed: 0 additions & 98 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: 43 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)