added siteIDs
TODO : handle le assign user to sites
MODIFY
src/async-task/tasks/UsersImportAsyncTask.ts
src/async-task/tasks/UsersImportAsyncTask.ts
@@ -78,6 +78,7 @@ export default class UsersImportAsyncTask extends AbstractAsyncTask {
await UserStorage.saveUserRole(tenant.id, newUser.id, UserRole.BASIC);
// Status need to be set separately
await UserStorage.saveUserStatus(tenant.id, newUser.id, newUser.status);
+ // TODO: add la gestion du assign des siteids
await UserStorage.deleteImportedUser(tenant.id, importedUser.id);
// Handle sending email for reseting password if user auto activated
// Init Password info

MODIFY
src/server/rest/v1/service/UserService.ts
src/server/rest/v1/service/UserService.ts
@@ -45,6 +45,7 @@ import UtilsSecurity from './security/UtilsSecurity';
import UtilsService from './UtilsService';
import csvToJson from 'csvtojson/v2';
import moment from 'moment';
+import sanitize from 'mongo-sanitize';
const MODULE_NAME = 'UserService';
@@ -1230,6 +1231,7 @@ export default class UserService {
firstName: importedUser.firstName,
email: importedUser.email,
autoActivateAtImport: importedUser.autoActivateAtImport,
+ siteIDs: importedUser.siteIDs
};
// Validate User data
UserValidator.getInstance().validateImportedUserCreation(newImportedUser);

MODIFY
src/storage/mongodb/UserStorage.ts
src/storage/mongodb/UserStorage.ts
@@ -286,6 +286,7 @@ export default class UserStorage {
importedOn: Utils.convertToDate(importedUserToSave.importedOn),
importedBy: Utils.convertToObjectID(importedUserToSave.importedBy),
autoActivateAtImport: importedUserToSave.autoActivateAtImport,
+ siteIDs: importedUserToSave.siteIDs,
};
await global.database.getCollection<any>(tenantID, 'importedusers').findOneAndUpdate(
{ _id: userMDB._id },
@@ -309,6 +310,7 @@ export default class UserStorage {
importedOn: Utils.convertToDate(importedUserToSave.importedOn),
importedBy: Utils.convertToObjectID(importedUserToSave.importedBy),
autoActivateAtImport: importedUserToSave.autoActivateAtImport,
+ siteIDs: importedUserToSave.siteIDs,
}));
// Insert all at once
const result = await global.database.getCollection<any>(tenantID, 'importedusers').insertMany(

MODIFY
src/types/User.ts
src/types/User.ts
@@ -67,6 +67,7 @@ export interface ImportedUser {
status?: ImportStatus
errorDescription?: string;
autoActivateAtImport?: boolean;
+ siteIDs?: string[];
}
export enum UserStatus {

added siteIDs
TODO : handle le assign user to sites