@@ -58,7 +58,7 @@ async function lookupCurrentUser(params, options) {
5858 logger . debug ( `Trying to authorize user based on Authorization header.` ) ;
5959 user . loginName = await _getCurrentGWUser ( headers = { 'Authorization' : `${ requestHeaders . authorization } ` } ) ;
6060 logger . debug ( `Authorized user is: ${ user . loginName } ` ) ;
61- permissions = await _getCurrentGWPermissions ( headers = { 'Authorization' : `${ requestHeaders . authorization } ` } , loginName ) ;
61+ permissions = await _getCurrentGWPermissions ( headers = { 'Authorization' : `${ requestHeaders . authorization } ` } , user . loginName ) ;
6262 } else {
6363 VIDUSR = _getCookie ( requestHeaders . cookie , "VIDUSR" ) ;
6464 if ( ! VIDUSR ) {
@@ -75,7 +75,7 @@ async function lookupCurrentUser(params, options) {
7575 logger . trace ( `Trying to get current user based on VIDUSR cookie.` ) ;
7676 user . loginName = await _getCurrentGWUser ( headers = { 'Cookie' : `VIDUSR=${ VIDUSR } ` } ) ;
7777 logger . trace ( `Current user is: ${ user . loginName } ` ) ;
78- permissions = await _getCurrentGWPermissions ( headers = { 'Cookie' : `VIDUSR=${ VIDUSR } ` , 'csrf-token' : requestHeaders [ 'csrf-token' ] } , loginName ) ;
78+ permissions = await _getCurrentGWPermissions ( headers = { 'Cookie' : `VIDUSR=${ VIDUSR } ` , 'csrf-token' : requestHeaders [ 'csrf-token' ] } , user . loginName ) ;
7979 }
8080 if ( permissions . includes ( "adminusers_modify" ) ) {
8181 user . gatewayManager . isAdmin = true ;
@@ -363,12 +363,13 @@ async function _getGroupRegionFilename(basefilename, groupId, region) {
363363}
364364
365365async function _getCurrentGWUser ( requestHeaders ) {
366+ debugger ;
366367 var options = {
367368 path : '/api/rbac/currentuser' ,
368369 headers : requestHeaders ,
369370 agent : new https . Agent ( { rejectUnauthorized : false } )
370371 } ;
371- const loginName = await sendRequest ( pluginConfig . apigateway . url , options )
372+ var loginName = await sendRequest ( pluginConfig . apigateway . url , options )
372373 . then ( response => {
373374 return response . body . result ;
374375 } )
@@ -475,7 +476,7 @@ async function _getCurrentGWPermissions(requestHeaders, loginName) {
475476 headers : requestHeaders ,
476477 agent : new https . Agent ( { rejectUnauthorized : false } )
477478 } ;
478- const result = await sendRequest ( pluginConfig . apigateway . url , options )
479+ var result = await sendRequest ( pluginConfig . apigateway . url , options )
479480 . then ( response => {
480481 return response . body . result ;
481482 } )
@@ -497,7 +498,7 @@ async function _getManagerUser(user, groupId) {
497498 } ,
498499 agent : new https . Agent ( { rejectUnauthorized : false } )
499500 } ;
500- const managerUser = await sendRequest ( apiManagerConfig . url , options )
501+ var managerUser = await sendRequest ( apiManagerConfig . url , options )
501502 . then ( response => {
502503 return response . body ;
503504 } )
@@ -552,11 +553,12 @@ async function _getOrganization(apiProxy, groupId, region, options) {
552553 if ( apiProxy . organizationName == undefined ) apiProxy . organizationName = "N/A" ;
553554 return apiProxy ;
554555 }
556+ var org ;
555557 const orgId = apiProxy . organizationId ;
556558 const apiManagerConfig = getManagerConfig ( pluginConfig . apimanager , groupId , region ) ;
557559 const orgCacheKey = `ORG-${ orgId } ###${ groupId } ###${ region } `
558560 if ( cache . has ( orgCacheKey ) ) {
559- var org = cache . get ( orgCacheKey ) ;
561+ org = cache . get ( orgCacheKey ) ;
560562 logger . debug ( `Organization: '${ org . name } ' (ID: ${ orgId } ) found in cache for groupId: ${ groupId } in region: ${ region } .` ) ;
561563 return org ;
562564 }
@@ -567,7 +569,7 @@ async function _getOrganization(apiProxy, groupId, region, options) {
567569 } ,
568570 agent : new https . Agent ( { rejectUnauthorized : false } )
569571 } ;
570- const org = await sendRequest ( apiManagerConfig . url , options )
572+ org = await sendRequest ( apiManagerConfig . url , options )
571573 . then ( response => {
572574 if ( ! response . body ) {
573575 throw new Error ( `Organization with : '${ orgId } ' not found in API-Manager.` ) ;
@@ -591,8 +593,9 @@ async function _getConfiguredCustomProperties(groupId, region, options) {
591593 const { logger } = options ;
592594 const apiManagerConfig = getManagerConfig ( pluginConfig . apimanager , groupId , region ) ;
593595 const customPropCacheKey = `CUSTOM_PROPERTIES###${ groupId } ###${ region } `
596+ var propertiesConfig ;
594597 if ( cache . has ( customPropCacheKey ) ) {
595- var propertiesConfig = cache . get ( customPropCacheKey ) ;
598+ propertiesConfig = cache . get ( customPropCacheKey ) ;
596599 logger . debug ( `Custom properties found in cache with groupId: ${ groupId } and region ${ region } .` ) ;
597600 return propertiesConfig ;
598601 }
@@ -604,7 +607,7 @@ async function _getConfiguredCustomProperties(groupId, region, options) {
604607 } ,
605608 agent : new https . Agent ( { rejectUnauthorized : false } )
606609 } ;
607- const propertiesConfig = await sendRequest ( apiManagerConfig . url , options )
610+ propertiesConfig = await sendRequest ( apiManagerConfig . url , options )
608611 . then ( response => {
609612 if ( ! response . body ) {
610613 throw new Error ( `Error getting custom properties from API-Manager: ${ apiManagerConfig . ur } ` ) ;
0 commit comments