Added getuser validation
MODIFY
src/assets/server/rest/v1/schemas/user/user-get-by-id.json
src/assets/server/rest/v1/schemas/user/user-get-by-id.json
"definitions": {
"ID": {
"$ref": "common.json#/definitions/id"
+ },
+ "ProjectFields": {
+ "$ref": "common.json#/definitions/projectFields"
}
},
"required": [

MODIFY
src/server/rest/v1/service/UserService.ts
src/server/rest/v1/service/UserService.ts
@@ -51,7 +51,7 @@ export default class UserService {
public static async handleGetUserDefaultTagCar(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
// Filter
- const userID = UserValidator.getInstance().validateUserGetByID(req.query).ID as string;
+ const userID = UserValidator.getInstance().validateUserGetByID(req.query).ID.toString();
UtilsService.assertIdIsProvided(action, userID, MODULE_NAME, 'handleGetUserDefaultTagCar', req.user);
// Check and Get User
const user = await UtilsService.checkAndGetUserAuthorization(
@@ -121,7 +121,7 @@ export default class UserService {
public static async handleDeleteUser(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
// Filter
- const userID = UserSecurity.filterUserByIDRequest(req.query);
+ const userID = UserValidator.getInstance().validateUserGetByID(req.query).ID.toString();
// Check and Get User
const user = await UtilsService.checkAndGetUserAuthorization(
req.tenant, req.user, userID, Action.DELETE, action);
@@ -297,11 +297,11 @@ export default class UserService {
public static async handleGetUser(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
// Filter
- const filteredRequest = UserSecurity.filterUserRequest(req.query);
+ const filteredRequest = UserValidator.getInstance().validateUserGetByID(req.query);
UtilsService.assertIdIsProvided(action, filteredRequest.ID, MODULE_NAME, 'handleGetUser', req.user);
// Check and Get User
const user = await UtilsService.checkAndGetUserAuthorization(
- req.tenant, req.user, filteredRequest.ID, Action.READ, action, {
+ req.tenant, req.user, filteredRequest.ID.toString(), Action.READ, action, {
withImage: true
}, true);
res.json(user);
@@ -310,7 +310,7 @@ export default class UserService {
public static async handleGetUserImage(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
// Filter
- const userID = UserSecurity.filterUserByIDRequest(req.query);
+ const userID = UserValidator.getInstance().validateUserGetByID(req.query).ID.toString();
// Check and Get User
const user = await UtilsService.checkAndGetUserAuthorization(
req.tenant, req.user, userID, Action.READ, action);

Added getuser validation