@@ -13,16 +13,26 @@ const { computeHash } = require('../examples/validateWebhookMessage');
1313
1414const eg001ValidateWebhookMessage = exports ;
1515const exampleNumber = 1 ;
16- const eg = `eg00 ${ exampleNumber } ` ; // This example reference.
16+ const eg = `cneg00 ${ exampleNumber } ` ; // This example reference.
1717const api = API_TYPES . CONNECT ;
18- const mustAuthenticate = " /ds/mustAuthenticate" ;
18+ const mustAuthenticate = ' /ds/mustAuthenticateJWT' ;
1919
2020/**
2121 * Create the envelope
2222 * @param {object } req Request obj
2323 * @param {object } res Response obj
2424 */
2525eg001ValidateWebhookMessage . createController = async ( req , res ) => {
26+ // Check that the authentication token is ok with a long buffer time.
27+ // If needed, now is the best time to ask the user to authenticate
28+ // since they have not yet entered any information into the form.
29+ const isTokenOK = req . dsAuth . checkToken ( ) ;
30+ if ( ! isTokenOK ) {
31+ // Save the current operation so it will be resumed after authentication
32+ req . dsAuth . setEg ( req , eg ) ;
33+ return res . redirect ( mustAuthenticate ) ;
34+ }
35+
2636 // Call the worker method
2737 const { body } = req ;
2838 const args = {
@@ -62,7 +72,7 @@ eg001ValidateWebhookMessage.getController = (req, res) => {
6272 req . dsAuth . setEg ( req , eg ) ;
6373 return res . redirect ( mustAuthenticate ) ;
6474 }
65-
75+
6676 const example = getExampleByNumber ( res . locals . manifest , exampleNumber , api ) ;
6777 const sourceFile =
6878 path . basename ( __filename ) [ 5 ] . toLowerCase ( ) +
0 commit comments