Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit caa2fb6

Browse files
authored
Merge pull request #489 from appirio-tech/dev
Promote Dev to Master - Terms noauth changes
2 parents e8d29a7 + 4cf63ba commit caa2fb6

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

actions/terms.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,25 @@ function validateTermsOfUseId(connection, helper, sqlParams, callback) {
4949
var getTermsOfUse = function (api, connection, dbConnectionMap, next) {
5050
var helper = api.helper,
5151
sqlParams = {},
52-
result = {};
52+
result = {},
53+
noauth = connection.params.noauth == "true";
5354

5455
//Check if the user is logged-in
55-
if (connection.caller.accessLevel === "anon") {
56+
if (!noauth && connection.caller.accessLevel === "anon") {
5657
helper.handleError(api, connection, new UnauthorizedError("Authentication credential was missing."));
5758
next(connection, true);
5859
return;
5960
}
6061

61-
sqlParams.userId = connection.caller.userId;
62+
sqlParams.userId = connection.caller ? connection.caller.userId || '' : '';
6263

6364
async.waterfall([
6465
function (cb) {
6566
// validate termsOfUseId parameter and set sql parameter
6667
validateTermsOfUseId(connection, helper, sqlParams, cb);
6768
},
6869
function (cb) {
69-
api.dataAccess.executeQuery("get_terms_of_use", sqlParams, dbConnectionMap, cb);
70+
api.dataAccess.executeQuery(noauth ? "get_terms_of_use_noauth" : "get_terms_of_use", sqlParams, dbConnectionMap, cb);
7071
}, function (rows, cb) {
7172
if (rows.length === 0) {
7273
cb(new NotFoundError('No such terms of use exists.'));
@@ -211,7 +212,7 @@ exports.getTermsOfUse = {
211212
description: "getTermsOfUse",
212213
inputs: {
213214
required: ["termsOfUseId"],
214-
optional: []
215+
optional: ["noauth"]
215216
},
216217
blockedConnectionTypes: [],
217218
outputExample: {},

queries/get_terms_of_use_noauth

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
SELECT tou.terms_of_use_id as terms_of_use_id,
2+
tou.title as title,
3+
tou.url as url,
4+
tou.terms_text as text,
5+
touat.terms_of_use_agreeability_type_id as agreeability_type_id,
6+
toudtx.docusign_template_id as docusign_template_id
7+
FROM terms_of_use tou
8+
INNER JOIN terms_of_use_agreeability_type_lu touat ON touat.terms_of_use_agreeability_type_id = tou.terms_of_use_agreeability_type_id
9+
LEFT JOIN terms_of_use_docusign_template_xref toudtx ON toudtx.terms_of_use_id = tou.terms_of_use_id
10+
WHERE tou.terms_of_use_id = @termsOfUseId@

queries/get_terms_of_use_noauth.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name" : "get_terms_of_use_noauth",
3+
"db" : "common_oltp",
4+
"sqlfile" : "get_terms_of_use_noauth"
5+
}

0 commit comments

Comments
 (0)