@@ -49,24 +49,25 @@ function validateTermsOfUseId(connection, helper, sqlParams, callback) {
4949var 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 : { } ,
0 commit comments