Added user creation schema
MODIFY
src/assets/server/rest/v1/schemas/user/user-create.json
src/assets/server/rest/v1/schemas/user/user-create.json
"required": [
"name",
"email",
- "subdomain"
+ "passwords"
]
}

MODIFY
src/server/rest/v1/service/UserService.ts
src/server/rest/v1/service/UserService.ts
@@ -983,7 +983,7 @@ export default class UserService {
});
}
// Filter
- const filteredRequest = UserSecurity.filterUserCreateRequest(req.body, req.user);
+ const filteredRequest = UserValidator.getInstance().validateUserCreate(req.body, req.user);
// Check Mandatory fields
UtilsService.checkIfUserValid(filteredRequest, null, req);
// Get the email

MODIFY
src/server/rest/v1/validator/UserValidator.ts
src/server/rest/v1/validator/UserValidator.ts
import User, { ImportedUser } from '../../../../types/User';
import Authorizations from '../../../../authorization/Authorizations';
-import { HttpUserRequest } from '../../../../types/requests/HttpUserRequest';
import Schema from '../../../../types/validator/Schema';
import SchemaValidator from './SchemaValidator';
import UserToken from '../../../../types/UserToken';
@@ -33,13 +32,14 @@ export default class UserValidator extends SchemaValidator {
this.validate(this.importedUserCreation, importedUser);
}
- validateUserCreate(user: Partial<User>, loggedUser: UserToken): Partial<User> {
+ validateUserCreate(user: any, loggedUser: UserToken): Partial<User> {
const request = Utils.cloneObject(user);
this.validate(this.userCreate, user);
if (Authorizations.isAdmin(loggedUser) || Authorizations.isSuperAdmin(loggedUser)) {
this.validate(this.userAdminCreate, request);
- user = { ...user, ...request };
+ user = request;
}
+ user.password = user.passwords.password;
return user;
}
}

Added user creation schema