update and create user
MODIFY
src/server/rest/v1/service/UserService.ts
src/server/rest/v1/service/UserService.ts
@@ -226,6 +226,8 @@ export default class UserService {
if (filteredRequest.role) {
await UserStorage.saveUserRole(req.tenant, user.id, filteredRequest.role);
}
+ // Save Technical user flag
+ await UserStorage.saveUserTechnicalFlag(req.tenant, user.id, user.technical);
// Save Admin Data
if (Utils.objectHasProperty(filteredRequest, 'plateID')) {
const adminData: { plateID?: string; } = {};
@@ -677,6 +679,8 @@ export default class UserService {
if (newUser.role) {
await UserStorage.saveUserRole(req.tenant, newUser.id, newUser.role);
}
+ // Save Technical user flag
+ await UserStorage.saveUserTechnicalFlag(req.tenant, newUser.id, newUser.technical);
// Save Admin Data
if (newUser.plateID || Utils.objectHasProperty(newUser, 'notificationsActive')) {
const adminData: { plateID?: string; notificationsActive?: boolean; notifications?: UserNotifications } = {};

MODIFY
src/storage/mongodb/UserStorage.ts
src/storage/mongodb/UserStorage.ts
import FeatureToggles, { Feature } from '../../utils/FeatureToggles';
import Site, { SiteUser } from '../../types/Site';
+import Tenant, { TenantComponents } from '../../types/Tenant';
import User, { ImportedUser, UserRole, UserStatus } from '../../types/User';
import { UserInError, UserInErrorType } from '../../types/InError';
import global, { FilterParams, Image, ImportStatus } from '../../types/GlobalType';
@@ -17,8 +18,6 @@ import Logging from '../../utils/Logging';
import Mustache from 'mustache';
import { ObjectId } from 'mongodb';
import TagStorage from './TagStorage';
-import Tenant from '../../types/Tenant';
-import { TenantComponents } from '../../types/Tenant';
import TenantStorage from './TenantStorage';
import UserNotifications from '../../types/UserNotifications';
import Utils from '../../utils/Utils';
@@ -455,6 +454,19 @@ export default class UserStorage {
await Logging.traceEnd(tenant.id, MODULE_NAME, 'saveUserRole', uniqueTimerID);
}
+ public static async saveUserTechnicalFlag(tenant: Tenant, userID: string, flag: boolean): Promise<void> {
+ // Debug
+ const uniqueTimerID = Logging.traceStart(tenant.id, MODULE_NAME, 'saveUserTechnicalFlag');
+ // Check Tenant
+ DatabaseUtils.checkTenantObject(tenant);
+ // Modify and return the modified document
+ await global.database.getCollection<any>(tenant.id, 'users').findOneAndUpdate(
+ { '_id': DatabaseUtils.convertToObjectID(userID) },
+ { $set: { technical: flag === true } });
+ // Debug
+ await Logging.traceEnd(tenant.id, MODULE_NAME, 'saveUserTechnicalFlag', uniqueTimerID);
+ }
+
public static async saveUserEULA(tenant: Tenant, userID: string,
params: { eulaAcceptedHash: string; eulaAcceptedOn: Date; eulaAcceptedVersion: number }): Promise<void> {
// Debug

update and create user