tango-app-api-audit 3.5.27 → 3.5.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1131,42 +1131,67 @@ export async function summaryList( req, res ) {
|
|
|
1131
1131
|
}
|
|
1132
1132
|
|
|
1133
1133
|
|
|
1134
|
-
if ( inputData.keyType === 'rm' ) {
|
|
1135
|
-
|
|
1136
|
-
{
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
completedFiles: 0,
|
|
1142
|
-
tangoScore: 0,
|
|
1143
|
-
trustScore: 0,
|
|
1134
|
+
if ( inputData.keyType === 'rm' || inputData.keyType === 'cluster' ) {
|
|
1135
|
+
const clusterQuery =[
|
|
1136
|
+
{ $match: {
|
|
1137
|
+
$and: [
|
|
1138
|
+
{ 'Teamlead.email': { $in: inputData.RMList } },
|
|
1139
|
+
{ clientId: { $eq: inputData?.clientId } },
|
|
1140
|
+
],
|
|
1144
1141
|
},
|
|
1142
|
+
},
|
|
1143
|
+
{ $unwind: { path: '$Teamlead', preserveNullAndEmptyArrays: true } },
|
|
1144
|
+
{ $unwind: { path: '$stores', preserveNullAndEmptyArrays: true } },
|
|
1145
|
+
{
|
|
1146
|
+
$group: {
|
|
1147
|
+
_id: { clusterName: '$clusterName', RMName: '$Teamlead.email' },
|
|
1148
|
+
clusterName: { $first: '$clusterName' },
|
|
1149
|
+
RMName: { $first: '$Teamlead.email' },
|
|
1150
|
+
store: { $addToSet: '$stores.storeId' },
|
|
1145
1151
|
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1152
|
+
},
|
|
1153
|
+
},
|
|
1154
|
+
{ $project: {
|
|
1155
|
+
RMName: 1,
|
|
1156
|
+
clusterName: 1,
|
|
1157
|
+
storesCount: { $size: '$store' },
|
|
1158
|
+
store: 1,
|
|
1159
|
+
} },
|
|
1160
|
+
];
|
|
1161
|
+
const RMQuery =[
|
|
1162
|
+
{ $match: {
|
|
1163
|
+
$and: [
|
|
1164
|
+
{
|
|
1165
|
+
'Teamlead.email': { $in: inputData.RMList },
|
|
1166
|
+
},
|
|
1167
|
+
{
|
|
1168
|
+
'clientId': { $eq: inputData?.clientId },
|
|
1169
|
+
},
|
|
1170
|
+
],
|
|
1171
|
+
},
|
|
1172
|
+
},
|
|
1173
|
+
{ $unwind: { path: '$Teamlead', preserveNullAndEmptyArrays: true } },
|
|
1150
1174
|
{ $unwind: { path: '$stores', preserveNullAndEmptyArrays: true } },
|
|
1151
1175
|
{
|
|
1152
1176
|
$group: {
|
|
1153
|
-
_id: '$
|
|
1177
|
+
_id: '$Teamlead.email',
|
|
1154
1178
|
clusterName: { $first: '$clusterName' },
|
|
1179
|
+
RMName: { $first: '$Teamlead.email' },
|
|
1155
1180
|
store: { $addToSet: '$stores.storeId' },
|
|
1156
1181
|
|
|
1157
1182
|
},
|
|
1158
1183
|
},
|
|
1159
1184
|
{ $project: {
|
|
1160
|
-
RMName:
|
|
1185
|
+
RMName: 1,
|
|
1161
1186
|
clusterName: 1,
|
|
1162
1187
|
storesCount: { $size: '$store' },
|
|
1163
1188
|
store: 1,
|
|
1164
1189
|
} },
|
|
1165
1190
|
];
|
|
1166
|
-
const getCluster = await aggregateClusters( clusterQuery );
|
|
1191
|
+
const getCluster = await aggregateClusters( inputData.keyType === 'rm'?RMQuery: clusterQuery );
|
|
1167
1192
|
logger.info( { getCluster: getCluster } );
|
|
1168
1193
|
if ( !getCluster || getCluster?.length == 0 ) {
|
|
1169
|
-
return res.sendError( 'No data',
|
|
1194
|
+
return res.sendError( 'No data', 204 );
|
|
1170
1195
|
}
|
|
1171
1196
|
const temp =[];
|
|
1172
1197
|
for ( const [ i, cluster ] of getCluster.entries() ) {
|
|
@@ -146,14 +146,7 @@ export const summaryListSchema = joi.object( {
|
|
|
146
146
|
'any.required': 'Type is required',
|
|
147
147
|
'string.empty': 'Type cannot be empty',
|
|
148
148
|
} ),
|
|
149
|
-
clientId: joi.string().
|
|
150
|
-
is: 'tango',
|
|
151
|
-
then: joi.required().messages( {
|
|
152
|
-
'any.required': 'clientId is required',
|
|
153
|
-
'string.base': 'clientId must be a string',
|
|
154
|
-
} ),
|
|
155
|
-
otherwise: joi.optional(),
|
|
156
|
-
} ),
|
|
149
|
+
clientId: joi.string().required(),
|
|
157
150
|
demographics: joi.array().optional(),
|
|
158
151
|
RMList: joi.array().items(
|
|
159
152
|
joi.string().required(),
|
|
@@ -3,12 +3,14 @@ import { logger } from 'tango-app-api-middleware';
|
|
|
3
3
|
export async function roleValidation( req, res, next ) {
|
|
4
4
|
try {
|
|
5
5
|
const userRole = req?.user?.role;
|
|
6
|
+
req.body.clientId = req?.user?.userType == 'tango'? req?.body?.clientId : req?.user?.clientId;
|
|
6
7
|
switch ( userRole ) {
|
|
7
8
|
case 'user':
|
|
8
|
-
|
|
9
|
+
req.body.RMList = [ req?.user?.email ];
|
|
9
10
|
break;
|
|
10
11
|
case 'admin':
|
|
11
|
-
|
|
12
|
+
req.body.RMList = [ req?.user?.email ];
|
|
13
|
+
// delete req?.body?.RMList;
|
|
12
14
|
break;
|
|
13
15
|
case 'superadmin':
|
|
14
16
|
break;
|