@@ -28,11 +28,11 @@ eg009DeleteUserProductPermissionProfile.createController = async (req, res) => {
2828 req . flash ( "info" , "Sorry, you need to re-authenticate." ) ;
2929 // Save the current operation so it will be resumed after authentication
3030 req . dsAuth . setEg ( req , eg ) ;
31- res . redirect ( mustAuthenticate ) ;
31+ return res . redirect ( mustAuthenticate ) ;
3232 }
3333
3434 if ( ! req . session . clmEmail ) {
35- res . render ( "pages/admin-examples/eg009DeleteUserProductPermissionProfile" , {
35+ return res . render ( "pages/admin-examples/eg009DeleteUserProductPermissionProfile" , {
3636 eg : eg , csrfToken : req . csrfToken ( ) ,
3737 title : "Delete user product permission profiles using an email address" ,
3838 emailOk : false ,
@@ -89,12 +89,12 @@ eg009DeleteUserProductPermissionProfile.getController = async (req, res) => {
8989 req . flash ( "info" , "Sorry, you need to re-authenticate." ) ;
9090 // Save the current operation so it will be resumed after authentication
9191 req . dsAuth . setEg ( req , eg ) ;
92- res . redirect ( mustAuthenticate ) ;
92+ return res . redirect ( mustAuthenticate ) ;
9393 }
9494
9595 const sourceFile = ( path . basename ( __filename ) ) [ 5 ] . toLowerCase ( ) + ( path . basename ( __filename ) ) . substr ( 6 ) ;
9696 if ( ! req . session . clmEmail ) {
97- res . render ( "pages/admin-examples/eg009DeleteUserProductPermissionProfile" , {
97+ return res . render ( "pages/admin-examples/eg009DeleteUserProductPermissionProfile" , {
9898 eg : eg , csrfToken : req . csrfToken ( ) ,
9999 title : "Delete user product permission profiles using an email address" ,
100100 emailOk : false ,
@@ -117,32 +117,24 @@ eg009DeleteUserProductPermissionProfile.getController = async (req, res) => {
117117
118118 const productPermissionProfiles = await getProductPermissionProfilesByEmail ( args ) ;
119119 let permissionProfileList = [ ] ;
120- let clmProductId ;
121- let clmPermissionProfileName ;
122- let eSignProductId ;
123- let eSignPermissionProfileName ;
120+ let permissionName ;
124121
125122 if ( productPermissionProfiles && productPermissionProfiles . length > 0 ) {
126123 productPermissionProfiles . forEach ( product => {
127124 let permissionProfiles = product [ "permission_profiles" ] ;
128125
129126 permissionProfiles . forEach ( profile => {
130127 if ( product [ "product_name" ] . includes ( "CLM" ) ) {
131- clmPermissionProfileName = profile [ "permission_profile_name" ] ;
132- clmProductId = product [ "product_id" ] ;
128+ permissionName = `CLM - ${ profile [ "permission_profile_name" ] } ` ;
133129 } else {
134- eSignPermissionProfileName = profile [ "permission_profile_name" ] ;
135- eSignProductId = product [ "product_id" ] ;
130+ permissionName = `eSignature - ${ profile [ "permission_profile_name" ] } ` ;
131+ }
132+
133+ if ( permissionProfileList . filter ( prof => prof [ "productId" ] === product [ "product_id" ] ) . length === 0 ) {
134+ permissionProfileList . push ( { productId : product [ "product_id" ] , permissionName} )
136135 }
137136 } ) ;
138137 } ) ;
139-
140- if ( clmProductId !== undefined ) {
141- permissionProfileList . push ( { productId : clmProductId , permissionName : `CLM - ${ clmPermissionProfileName } ` } )
142- }
143- if ( eSignProductId !== undefined ) {
144- permissionProfileList . push ( { productId : eSignProductId , permissionName : `eSignature - ${ eSignPermissionProfileName } ` } )
145- }
146138 }
147139
148140 res . render ( "pages/admin-examples/eg009DeleteUserProductPermissionProfile" , {
0 commit comments