Added user-get-sites schema
ADD
src/assets/server/rest/v1/schemas/user/user-get-sites.json
+{
+ "title": "Get User sites",
+ "type": "object",
+ "definitions": {
+ "UserID": {
+ "$ref": "user.json#/definitions/id"
+ },
+ "Search": {
+ "$ref": "common.json#/definitions/search"
+ },
+ "Limit": {
+ "$ref": "common.json#/definitions/limit"
+ },
+ "SortFields": {
+ "$ref": "common.json#/definitions/sortFields"
+ },
+ "Skip": {
+ "$ref": "common.json#/definitions/skip"
+ },
+ "OnlyRecordCount": {
+ "$ref": "common.json#/definitions/onlyRecordCount"
+ },
+ "ProjectFields": {
+ "$ref": "common.json#/definitions/projectFields"
+ }
+ },
+ "required": [
+ "UserID"
+ ]
+}

MODIFY
src/server/rest/v1/service/UserService.ts
src/server/rest/v1/service/UserService.ts
@@ -332,7 +332,7 @@ export default class UserService {
UtilsService.assertComponentIsActiveFromToken(req.user, TenantComponents.ORGANIZATION,
Action.UPDATE, Entity.USER, MODULE_NAME, 'handleGetSites');
// Filter
- const filteredRequest = UserSecurity.filterUserSitesRequest(req.query);
+ const filteredRequest = UserValidator.getInstance().validateUserGetSites(req.query);
// Check User
try {
await UtilsService.checkAndGetUserAuthorization(

MODIFY
src/server/rest/v1/validator/UserValidator.ts
src/server/rest/v1/validator/UserValidator.ts
import User, { ImportedUser } from '../../../../types/User';
+import { HttpUserSitesRequest } from '../../../../types/requests/HttpUserRequest';
import Schema from '../../../../types/validator/Schema';
import SchemaValidator from './SchemaValidator';
import fs from 'fs';
@@ -9,11 +10,13 @@ export default class UserValidator extends SchemaValidator {
private static instance: UserValidator|null = null;
private importedUserCreation: Schema;
private userCreate: Schema;
+ private userGetSites: Schema;
private constructor() {
super('UserValidator');
this.importedUserCreation = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/user/imported-user-create-req.json`, 'utf8'));
this.userCreate = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/user/user-create.json`, 'utf8'));
+ this.userGetSites = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/user/user-get-sites.json`, 'utf8'));
}
public static getInstance(): UserValidator {
@@ -32,4 +35,9 @@ export default class UserValidator extends SchemaValidator {
user.password = user.passwords.password;
return user;
}
+
+ validateUserGetSites(data: any): HttpUserSitesRequest {
+ this.validate(this.userGetSites, data);
+ return data;
+ }
}

Added user-get-sites schema