@@ -49,24 +49,25 @@ function validateTermsOfUseId(connection, helper, sqlParams, callback) {
49
49
var getTermsOfUse = function ( api , connection , dbConnectionMap , next ) {
50
50
var helper = api . helper ,
51
51
sqlParams = { } ,
52
- result = { } ;
52
+ result = { } ,
53
+ noauth = connection . params . noauth == "true" ;
53
54
54
55
//Check if the user is logged-in
55
- if ( connection . caller . accessLevel === "anon" ) {
56
+ if ( ! noauth && connection . caller . accessLevel === "anon" ) {
56
57
helper . handleError ( api , connection , new UnauthorizedError ( "Authentication credential was missing." ) ) ;
57
58
next ( connection , true ) ;
58
59
return ;
59
60
}
60
61
61
- sqlParams . userId = connection . caller . userId ;
62
+ sqlParams . userId = connection . caller ? connection . caller . userId || '' : '' ;
62
63
63
64
async . waterfall ( [
64
65
function ( cb ) {
65
66
// validate termsOfUseId parameter and set sql parameter
66
67
validateTermsOfUseId ( connection , helper , sqlParams , cb ) ;
67
68
} ,
68
69
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 ) ;
70
71
} , function ( rows , cb ) {
71
72
if ( rows . length === 0 ) {
72
73
cb ( new NotFoundError ( 'No such terms of use exists.' ) ) ;
@@ -211,7 +212,7 @@ exports.getTermsOfUse = {
211
212
description : "getTermsOfUse" ,
212
213
inputs : {
213
214
required : [ "termsOfUseId" ] ,
214
- optional : [ ]
215
+ optional : [ "noauth" ]
215
216
} ,
216
217
blockedConnectionTypes : [ ] ,
217
218
outputExample : { } ,
0 commit comments