Skip to content

Commit

Permalink
Merge pull request #489 from appirio-tech/dev
Browse files Browse the repository at this point in the history
Promote Dev to Master - Terms noauth changes
  • Loading branch information
ajefts committed Sep 26, 2016
2 parents e8d29a7 + 4cf63ba commit caa2fb6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
11 changes: 6 additions & 5 deletions actions/terms.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,25 @@ function validateTermsOfUseId(connection, helper, sqlParams, callback) {
var getTermsOfUse = function (api, connection, dbConnectionMap, next) {
var helper = api.helper,
sqlParams = {},
result = {};
result = {},
noauth = connection.params.noauth == "true";

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

sqlParams.userId = connection.caller.userId;
sqlParams.userId = connection.caller ? connection.caller.userId || '' : '';

async.waterfall([
function (cb) {
// validate termsOfUseId parameter and set sql parameter
validateTermsOfUseId(connection, helper, sqlParams, cb);
},
function (cb) {
api.dataAccess.executeQuery("get_terms_of_use", sqlParams, dbConnectionMap, cb);
api.dataAccess.executeQuery(noauth ? "get_terms_of_use_noauth" : "get_terms_of_use", sqlParams, dbConnectionMap, cb);
}, function (rows, cb) {
if (rows.length === 0) {
cb(new NotFoundError('No such terms of use exists.'));
Expand Down Expand Up @@ -211,7 +212,7 @@ exports.getTermsOfUse = {
description: "getTermsOfUse",
inputs: {
required: ["termsOfUseId"],
optional: []
optional: ["noauth"]
},
blockedConnectionTypes: [],
outputExample: {},
Expand Down
10 changes: 10 additions & 0 deletions queries/get_terms_of_use_noauth
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
SELECT tou.terms_of_use_id as terms_of_use_id,
tou.title as title,
tou.url as url,
tou.terms_text as text,
touat.terms_of_use_agreeability_type_id as agreeability_type_id,
toudtx.docusign_template_id as docusign_template_id
FROM terms_of_use tou
INNER JOIN terms_of_use_agreeability_type_lu touat ON touat.terms_of_use_agreeability_type_id = tou.terms_of_use_agreeability_type_id
LEFT JOIN terms_of_use_docusign_template_xref toudtx ON toudtx.terms_of_use_id = tou.terms_of_use_id
WHERE tou.terms_of_use_id = @termsOfUseId@
5 changes: 5 additions & 0 deletions queries/get_terms_of_use_noauth.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name" : "get_terms_of_use_noauth",
"db" : "common_oltp",
"sqlfile" : "get_terms_of_use_noauth"
}

0 comments on commit caa2fb6

Please sign in to comment.