Skip to content

Commit 189e47a

Browse files
fixes and removing auth
1 parent bee8b39 commit 189e47a

File tree

4 files changed

+27
-54
lines changed

4 files changed

+27
-54
lines changed

lib/connect/controllers/eg001ValidateWebhookMessage.js

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,6 @@ const mustAuthenticate = '/ds/mustAuthenticateJWT';
2323
* @param {object} res Response obj
2424
*/
2525
eg001ValidateWebhookMessage.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-
3626
// Call the worker method
3727
const { body } = req;
3828
const args = {
@@ -44,8 +34,8 @@ eg001ValidateWebhookMessage.createController = async (req, res) => {
4434
try {
4535
results = computeHash(args);
4636
} catch (error) {
47-
const errorCode = error && error.code;
48-
const errorMessage = error && error.message;
37+
const errorCode = error?.code;
38+
const errorMessage = error?.message;
4939
// In production, may want to provide customized error messages and
5040
// remediation advice to the user.
5141
res.render('pages/error', { err: error, errorCode, errorMessage });
@@ -63,16 +53,6 @@ eg001ValidateWebhookMessage.createController = async (req, res) => {
6353
* Form page for this application
6454
*/
6555
eg001ValidateWebhookMessage.getController = (req, res) => {
66-
// Check that the authentication token is ok with a long buffer time.
67-
// If needed, now is the best time to ask the user to authenticate
68-
// since they have not yet entered any information into the form.
69-
const isTokenOK = req.dsAuth.checkToken();
70-
if (!isTokenOK) {
71-
// Save the current operation so it will be resumed after authentication
72-
req.dsAuth.setEg(req, eg);
73-
return res.redirect(mustAuthenticate);
74-
}
75-
7656
const example = getExampleByNumber(res.locals.manifest, exampleNumber, api);
7757
const sourceFile =
7858
path.basename(__filename)[5].toLowerCase() +

public/assets/search.js

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const DS_SEARCH = (function () {
2929
if (
3030
name === matches[i].value ||
3131
description === matches[i].value ||
32-
pathNames.indexOf(matches[i].value) > -1
32+
pathNames && pathNames.indexOf(matches[i].value) > -1
3333
) {
3434
return true;
3535
}
@@ -175,8 +175,9 @@ const DS_SEARCH = (function () {
175175
);
176176

177177
$("#filtered_code_examples").append("<p>");
178-
if (example.LinksToAPIMethod && example.LinksToAPIMethod.length !== 0) {
179-
if (example.LinksToAPIMethod.length == 1) {
178+
const links = example.LinksToAPIMethod || [];
179+
if (links.length > 0) {
180+
if (links.length == 1) {
180181
$("#filtered_code_examples").append(
181182
processJSONData().SupportingTexts.APIMethodUsed
182183
);
@@ -186,27 +187,18 @@ const DS_SEARCH = (function () {
186187
);
187188
}
188189

189-
for (
190-
let index = 0;
191-
index < example.LinksToAPIMethod.length;
192-
index++
193-
) {
194-
$("#filtered_code_examples").append(
195-
" <a target='_blank' href='" +
196-
example.LinksToAPIMethod[index].Path +
197-
"'>" +
198-
example.LinksToAPIMethod[index].PathName +
199-
"</a>"
200-
);
190+
links.forEach((link, index) => {
191+
$("#filtered_code_examples").append(`<a target='_blank' href='${link.Path}'>${link.PathName}</a>`);
201192

202-
if (index + 1 === example.LinksToAPIMethod.length) {
193+
if (index + 1 === links.length) {
203194
$("#filtered_code_examples").append("<span></span>");
204-
} else if (index + 1 === example.LinksToAPIMethod.length - 1) {
195+
} else if (index + 1 === links.length - 1) {
205196
$("#filtered_code_examples").append("<span> and </span>");
206197
} else {
207198
$("#filtered_code_examples").append("<span>, </span>");
208199
}
209-
}
200+
})
201+
210202
}
211203

212204
$("#filtered_code_examples").append("</p> ");
@@ -268,12 +260,10 @@ function updateValue(esearchPattern) {
268260
})[0];
269261

270262
group.Examples.forEach((example, index) => {
271-
const clearedExample = unfilteredGroup.Examples.filter(
272-
(apiExample) => {
273-
return apiExample.ExampleNumber === example.ExampleNumber;
274-
}
275-
)[0];
276-
x.item.Groups[groupIndex].Examples[index] = clearedExample;
263+
const clearedExamples = unfilteredGroup.Examples.filter((apiExample) => {
264+
return apiExample.ExampleNumber === example.ExampleNumber;
265+
})
266+
x.item.Groups[groupIndex].Examples[index] = clearedExamples[0];
277267
});
278268
});
279269

views/pages/index_examples_list.ejs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@
3232
<p><%- example.ExampleDescription %></p>
3333
3434
<p>
35-
<% if (example.LinksToAPIMethod?.length > 1) { %>
36-
API methods used:
37-
<% } else { %>
38-
API method used:
35+
<% if (example.LinksToAPIMethod?.length > 0) { %>
36+
<% if (example.LinksToAPIMethod?.length > 1) { %>
37+
API methods used:
38+
<% } else { %>
39+
API method used:
40+
<% } %>
3941
<% } %>
4042
4143
<% example.LinksToAPIMethod?.forEach(function(link) { %>

views/partials/genericHead.ejs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<%- include("head") %>
22

33
<% if (locals.user) { %>
4-
<div class="container" style="padding-top:30px">
5-
<% } else { %>
6-
<div class="container-full-bg">
4+
<div class="container" style="padding-top:30px; margin-left: 90px;">
5+
<section id="content" style="margin-top:-60px!important; padding-top:30px!important;">
6+
<% } else { %>
7+
<div class="container-full-bg">
8+
<section id="content" style="margin:0 90px 0 90px; padding:0 15px 0 15px;">
79
<% } %>
8-
<section id="content" style="margin-top:-60px!important; padding-top:30px!important;">

0 commit comments

Comments
 (0)