Splitted getUsers/getUsersInError schemas
MODIFY
src/assets/server/rest/v1/schemas/user/users-get.json
src/assets/server/rest/v1/schemas/user/users-get.json
"sanitize": "mongo",
"pattern": "^[PAIBL](\\|[PAIBL])*$"
},
- "ErrorType": {
- "type": "string",
- "sanitize": "mongo",
- "pattern": "^((inactive_user|unassigned_user|inactive_user_account|failed_billing_synchro|no_billing_data)(\\||inactive_user|unassigned_user|inactive_user_account|failed_billing_synchro|no_billing_data)*)$"
- },
"ExcludeSiteID": {
"$ref": "common.json#/definitions/ids"
},

ADD
src/assets/server/rest/v1/schemas/user/users-inerror-get.json
+{
+ "title": "Get Users in error",
+ "type": "object",
+ "definitions": {
+ "Roles": {
+ "type": "string",
+ "sanitize": "mongo",
+ "pattern": "^[SABD](\\|[SABD])*$"
+ },
+ "ErrorType": {
+ "type": "string",
+ "sanitize": "mongo",
+ "pattern": "^((inactive_user|unassigned_user|inactive_user_account|failed_billing_synchro|no_billing_data)(\\||inactive_user|unassigned_user|inactive_user_account|failed_billing_synchro|no_billing_data)*)$"
+ },
+ "Search": {
+ "$ref": "common.json#/definitions/search"
+ },
+ "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": []
+}

MODIFY
src/server/rest/v1/service/UserService.ts
src/server/rest/v1/service/UserService.ts
@@ -382,7 +382,7 @@ export default class UserService {
public static async handleGetUsersInError(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
// Filter
- const filteredRequest = UserValidator.getInstance().validateUsersGet(req.query);
+ const filteredRequest = UserValidator.getInstance().validateUsersGetInError(req.query);
// Get authorization filters
const authorizationUserInErrorFilters = await AuthorizationService.checkAndGetUsersInErrorAuthorizationFilters(
req.tenant, req.user, filteredRequest);

MODIFY
src/server/rest/v1/validator/UserValidator.ts
src/server/rest/v1/validator/UserValidator.ts
-import { HttpUserAssignSitesRequest, HttpUsersRequest } from '../../../../types/requests/HttpUserRequest';
+import { HttpUserAssignSitesRequest, HttpUsersInErrorRequest, HttpUsersRequest } from '../../../../types/requests/HttpUserRequest';
import User, { ImportedUser } from '../../../../types/User';
import HttpByIDRequest from '../../../../types/requests/HttpByIDRequest';
@@ -14,6 +14,7 @@ export default class UserValidator extends SchemaValidator {
private userAssignSites: Schema;
private userGetByID: Schema;
private usersGet: Schema;
+ private usersGetInError: Schema;
private constructor() {
super('UserValidator');
@@ -22,6 +23,7 @@ export default class UserValidator extends SchemaValidator {
this.userAssignSites = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/user/user-assign-sites.json`, 'utf8'));
this.userGetByID = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/user/user-get.json`, 'utf8'));
this.usersGet = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/user/users-get.json`, 'utf8'));
+ this.usersGetInError = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/user/users-inerror-get.json`, 'utf8'));
}
public static getInstance(): UserValidator {
@@ -55,4 +57,9 @@ export default class UserValidator extends SchemaValidator {
this.validate(this.usersGet, data);
return data;
}
+
+ validateUsersGetInError(data: any): HttpUsersInErrorRequest {
+ this.validate(this.usersGetInError, data);
+ return data;
+ }
}

MODIFY
src/types/requests/HttpUserRequest.ts
src/types/requests/HttpUserRequest.ts
@@ -46,6 +46,12 @@ export interface HttpUsersRequest extends HttpDatabaseRequest {
NotAssignedToCarID: string;
}
+export interface HttpUsersInErrorRequest extends HttpDatabaseRequest {
+ Search: string;
+ Role?: string;
+ ErrorType?: string;
+}
+
export interface HttpUserSitesRequest extends HttpDatabaseRequest {
Search: string;
UserID: string;

Splitted getUsers/getUsersInError schemas