@ubs-platform/users-webservice 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_monaembed/@ubs-platform/users-consts/eo-channel-consts.d.ts +13 -0
- package/_monaembed/@ubs-platform/users-consts/eo-channel-consts.js +18 -0
- package/_monaembed/@ubs-platform/users-consts/eo-channel-consts.js.map +1 -0
- package/_monaembed/@ubs-platform/users-consts/eo-group-event.consts.d.ts +11 -0
- package/_monaembed/@ubs-platform/users-consts/eo-group-event.consts.js +16 -0
- package/_monaembed/@ubs-platform/users-consts/eo-group-event.consts.js.map +1 -0
- package/_monaembed/@ubs-platform/users-consts/index.d.ts +4 -0
- package/_monaembed/@ubs-platform/users-consts/index.js +21 -0
- package/_monaembed/@ubs-platform/users-consts/index.js.map +1 -0
- package/_monaembed/@ubs-platform/users-consts/jwt-consts.d.ts +4 -0
- package/_monaembed/@ubs-platform/users-consts/jwt-consts.js +9 -0
- package/_monaembed/@ubs-platform/users-consts/jwt-consts.js.map +1 -0
- package/_monaembed/@ubs-platform/users-consts/package.json +1 -0
- package/_monaembed/@ubs-platform/users-consts/tsconfig.lib-publish.tsbuildinfo +1 -0
- package/_monaembed/@ubs-platform/users-consts/user-events.d.ts +4 -0
- package/_monaembed/@ubs-platform/users-consts/user-events.js +9 -0
- package/_monaembed/@ubs-platform/users-consts/user-events.js.map +1 -0
- package/dto/email.dto.d.ts +7 -0
- package/dto/email.dto.js +3 -0
- package/dto/email.dto.js.map +1 -0
- package/guard/jwt-local.guard.d.ts +4 -0
- package/guard/jwt-local.guard.js +8 -0
- package/guard/jwt-local.guard.js.map +1 -0
- package/guard/user-intercept.d.ts +5 -0
- package/guard/user-intercept.js +23 -0
- package/guard/user-intercept.js.map +1 -0
- package/index.d.ts +25 -0
- package/index.js +42 -0
- package/index.js.map +1 -0
- package/local-current-user-decorator.d.ts +1 -0
- package/local-current-user-decorator.js +6 -0
- package/local-current-user-decorator.js.map +1 -0
- package/mapper/entity-ownership-group.mapper.d.ts +16 -0
- package/mapper/entity-ownership-group.mapper.js +61 -0
- package/mapper/entity-ownership-group.mapper.js.map +1 -0
- package/mapper/entity-ownership.mapper.d.ts +15 -0
- package/mapper/entity-ownership.mapper.js +80 -0
- package/mapper/entity-ownership.mapper.js.map +1 -0
- package/mapper/user.mapper.d.ts +17 -0
- package/mapper/user.mapper.js +163 -0
- package/mapper/user.mapper.js.map +1 -0
- package/package.json +1 -0
- package/services/auth.service.d.ts +12 -0
- package/services/auth.service.js +60 -0
- package/services/auth.service.js.map +1 -0
- package/services/email-change-request.service.d.ts +16 -0
- package/services/email-change-request.service.js +97 -0
- package/services/email-change-request.service.js.map +1 -0
- package/services/email.service.d.ts +8 -0
- package/services/email.service.js +43 -0
- package/services/email.service.js.map +1 -0
- package/services/entity-ownership-group.service.d.ts +53 -0
- package/services/entity-ownership-group.service.js +473 -0
- package/services/entity-ownership-group.service.js.map +1 -0
- package/services/entity-ownership.service.d.ts +39 -0
- package/services/entity-ownership.service.js +347 -0
- package/services/entity-ownership.service.js.map +1 -0
- package/services/password-reset.service.d.ts +15 -0
- package/services/password-reset.service.js +113 -0
- package/services/password-reset.service.js.map +1 -0
- package/services/user-common.service.d.ts +9 -0
- package/services/user-common.service.js +53 -0
- package/services/user-common.service.js.map +1 -0
- package/services/user-register.service.d.ts +20 -0
- package/services/user-register.service.js +137 -0
- package/services/user-register.service.js.map +1 -0
- package/services/user.service.d.ts +48 -0
- package/services/user.service.js +295 -0
- package/services/user.service.js.map +1 -0
- package/strategies/jwt-local-strategy.d.ts +11 -0
- package/strategies/jwt-local-strategy.js +37 -0
- package/strategies/jwt-local-strategy.js.map +1 -0
- package/users-webservice.module.d.ts +2 -0
- package/users-webservice.module.js +81 -0
- package/users-webservice.module.js.map +1 -0
- package/util/crypto-op.d.ts +4 -0
- package/util/crypto-op.js +15 -0
- package/util/crypto-op.js.map +1 -0
- package/util/eog-assertions.d.ts +12 -0
- package/util/eog-assertions.js +113 -0
- package/util/eog-assertions.js.map +1 -0
- package/web/auth.controller.d.ts +11 -0
- package/web/auth.controller.js +83 -0
- package/web/auth.controller.js.map +1 -0
- package/web/entity-ownership-group-member.controller.d.ts +17 -0
- package/web/entity-ownership-group-member.controller.js +154 -0
- package/web/entity-ownership-group-member.controller.js.map +1 -0
- package/web/entity-ownership-group-microservice.controller.d.ts +27 -0
- package/web/entity-ownership-group-microservice.controller.js +117 -0
- package/web/entity-ownership-group-microservice.controller.js.map +1 -0
- package/web/entity-ownership-group.controller.d.ts +17 -0
- package/web/entity-ownership-group.controller.js +141 -0
- package/web/entity-ownership-group.controller.js.map +1 -0
- package/web/entity-ownership.controller.d.ts +20 -0
- package/web/entity-ownership.controller.js +142 -0
- package/web/entity-ownership.controller.js.map +1 -0
- package/web/password-reset.controller.d.ts +16 -0
- package/web/password-reset.controller.js +61 -0
- package/web/password-reset.controller.js.map +1 -0
- package/web/user-admin.controller.d.ts +21 -0
- package/web/user-admin.controller.js +107 -0
- package/web/user-admin.controller.js.map +1 -0
- package/web/user-microservice.controller.d.ts +28 -0
- package/web/user-microservice.controller.js +97 -0
- package/web/user-microservice.controller.js.map +1 -0
- package/web/user-registration.controller.d.ts +11 -0
- package/web/user-registration.controller.js +67 -0
- package/web/user-registration.controller.js.map +1 -0
- package/web/user.controller.d.ts +24 -0
- package/web/user.controller.js +110 -0
- package/web/user.controller.js.map +1 -0
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var EntityOwnershipGroupService_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.EntityOwnershipGroupService = void 0;
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const mongoose_1 = require("@nestjs/mongoose");
|
|
19
|
+
const mongoose_2 = require("mongoose");
|
|
20
|
+
const users_common_1 = require("@ubs-platform/users-common");
|
|
21
|
+
const users_entity_mongo_1 = require("@ubs-platform/users-entity-mongo");
|
|
22
|
+
const entity_ownership_group_mapper_1 = require("../mapper/entity-ownership-group.mapper");
|
|
23
|
+
const user_service_1 = require("./user.service");
|
|
24
|
+
const users_entity_mongo_2 = require("@ubs-platform/users-entity-mongo");
|
|
25
|
+
const users_common_2 = require("@ubs-platform/users-common");
|
|
26
|
+
const email_service_1 = require("./email.service");
|
|
27
|
+
const crud_base_1 = require("@ubs-platform/crud-base");
|
|
28
|
+
const users_entity_mongo_3 = require("@ubs-platform/users-entity-mongo");
|
|
29
|
+
let EntityOwnershipGroupService = EntityOwnershipGroupService_1 = class EntityOwnershipGroupService {
|
|
30
|
+
constructor(eogModel, eogInvitationModel, mapper, userServiceLocal, emailService, eoModel) {
|
|
31
|
+
this.eogModel = eogModel;
|
|
32
|
+
this.eogInvitationModel = eogInvitationModel;
|
|
33
|
+
this.mapper = mapper;
|
|
34
|
+
this.userServiceLocal = userServiceLocal;
|
|
35
|
+
this.emailService = emailService;
|
|
36
|
+
this.eoModel = eoModel;
|
|
37
|
+
this.logger = new common_1.Logger(EntityOwnershipGroupService_1.name, {
|
|
38
|
+
timestamp: true,
|
|
39
|
+
});
|
|
40
|
+
this.APPLY_TK_LOTUS_MIGRATIONS = process.env['APPLY_TK_LOTUS_MIGRATIONS'] === undefined || process.env['APPLY_TK_LOTUS_MIGRATIONS'] === 'true';
|
|
41
|
+
}
|
|
42
|
+
async onModuleInit() {
|
|
43
|
+
this.logger.debug('EntityOwnershipGroupService initialized');
|
|
44
|
+
await Promise.all([
|
|
45
|
+
this.migrateAllGroupCapabilityToNewStructure(),
|
|
46
|
+
this.migrateAllGroupInvititaionCapabilityToNewStructure(),
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
49
|
+
async migrateAllGroupCapabilityToNewStructure() {
|
|
50
|
+
const allGroups = await this.eogModel.find({
|
|
51
|
+
$or: [{
|
|
52
|
+
"userCapabilities.groupCapability": { $exists: true },
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"userCapabilities.entityCapabilities.capability": { $exists: true },
|
|
56
|
+
}]
|
|
57
|
+
}).exec();
|
|
58
|
+
for (const group of allGroups) {
|
|
59
|
+
let modified = false;
|
|
60
|
+
for (const userCap of group.userCapabilities) {
|
|
61
|
+
if (userCap.groupCapability) {
|
|
62
|
+
userCap.groupCapabilities = (0, users_common_1.migrateFromStringToCapability)(userCap.groupCapability, this.APPLY_TK_LOTUS_MIGRATIONS);
|
|
63
|
+
delete userCap.groupCapability;
|
|
64
|
+
modified = true;
|
|
65
|
+
}
|
|
66
|
+
if (userCap.entityCapabilities) {
|
|
67
|
+
for (const entityCap of userCap.entityCapabilities) {
|
|
68
|
+
if (entityCap.capability) {
|
|
69
|
+
entityCap.capabilities = (0, users_common_1.migrateFromStringToCapability)(entityCap.capability, this.APPLY_TK_LOTUS_MIGRATIONS);
|
|
70
|
+
delete entityCap.capability;
|
|
71
|
+
modified = true;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (modified) {
|
|
77
|
+
group.markModified('userCapabilities');
|
|
78
|
+
await group.save();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async migrateAllGroupInvititaionCapabilityToNewStructure() {
|
|
83
|
+
const allGroups = await this.eogInvitationModel.find({
|
|
84
|
+
$or: [{
|
|
85
|
+
"groupCapability": { $exists: true },
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"entityCapabilities.capability": { $exists: true },
|
|
89
|
+
}]
|
|
90
|
+
}).exec();
|
|
91
|
+
for (const invitation of allGroups) {
|
|
92
|
+
let modified = false;
|
|
93
|
+
if (invitation.groupCapability) {
|
|
94
|
+
invitation.groupCapabilities = (0, users_common_1.migrateFromStringToCapability)(invitation.groupCapability, this.APPLY_TK_LOTUS_MIGRATIONS);
|
|
95
|
+
delete invitation.groupCapability;
|
|
96
|
+
modified = true;
|
|
97
|
+
}
|
|
98
|
+
if (invitation.entityCapabilities) {
|
|
99
|
+
for (const entityCap of invitation.entityCapabilities) {
|
|
100
|
+
if (entityCap.capability) {
|
|
101
|
+
entityCap.capabilities = (0, users_common_1.migrateFromStringToCapability)(entityCap.capability, this.APPLY_TK_LOTUS_MIGRATIONS);
|
|
102
|
+
delete entityCap.capability;
|
|
103
|
+
modified = true;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (modified) {
|
|
108
|
+
await invitation.save();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async deleteGroup(id) {
|
|
113
|
+
await this.eogModel.findByIdAndDelete(id).exec();
|
|
114
|
+
}
|
|
115
|
+
async createGroup(eogDto, userId) {
|
|
116
|
+
this.logger.debug('EOG CREATE', eogDto.name);
|
|
117
|
+
const entity = await this.mapper.toEntityCreate(eogDto, userId);
|
|
118
|
+
await entity.save();
|
|
119
|
+
return this.mapper.toDto(entity);
|
|
120
|
+
}
|
|
121
|
+
async editMeta(data) {
|
|
122
|
+
const a = await this.eogModel.findById(data.id).exec();
|
|
123
|
+
if (!a) {
|
|
124
|
+
throw new Error('EntityOwnershipGroup not found');
|
|
125
|
+
}
|
|
126
|
+
a.name = data.name;
|
|
127
|
+
a.description = data.description;
|
|
128
|
+
await a.save();
|
|
129
|
+
return this.mapper.toDto(a);
|
|
130
|
+
}
|
|
131
|
+
async fetchUsersInGroup(id) {
|
|
132
|
+
const found = await this.eogModel.findById(id).exec();
|
|
133
|
+
if (!found) {
|
|
134
|
+
throw new Error('EntityOwnershipGroup not found');
|
|
135
|
+
}
|
|
136
|
+
return found.userCapabilities.map((a) => {
|
|
137
|
+
return this.capabilityToDto(a);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
capabilityToDto(a) {
|
|
141
|
+
return {
|
|
142
|
+
userId: a.userId,
|
|
143
|
+
entityCapabilities: a.entityCapabilities?.map((ec) => ({
|
|
144
|
+
entityGroup: ec.entityGroup,
|
|
145
|
+
entityName: ec.entityName,
|
|
146
|
+
capabilities: ec.capabilities,
|
|
147
|
+
})),
|
|
148
|
+
groupCapabilities: a.groupCapabilities,
|
|
149
|
+
userFullName: a.userFullName,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
async hasUserGroupCapability(eogCheckCap) {
|
|
153
|
+
const group = await this.getById(eogCheckCap.entityOwnershipGroupId);
|
|
154
|
+
if (!group) {
|
|
155
|
+
throw new Error('EntityOwnershipGroup not found');
|
|
156
|
+
}
|
|
157
|
+
let requestedCapabilities = eogCheckCap.requestedCapabilities;
|
|
158
|
+
requestedCapabilities = requestedCapabilities;
|
|
159
|
+
let flag = false;
|
|
160
|
+
for (const requestedCapability of requestedCapabilities) {
|
|
161
|
+
const hasCap = group.userCapabilities?.some((uc) => uc.userId === eogCheckCap.userId &&
|
|
162
|
+
requestedCapability.every((cap) => uc.groupCapabilities.includes(cap)));
|
|
163
|
+
if (hasCap) {
|
|
164
|
+
flag = true;
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return flag;
|
|
169
|
+
}
|
|
170
|
+
async findGroupsUserIn(userIds) {
|
|
171
|
+
return this.eogModel
|
|
172
|
+
.find({ 'userCapabilities.userId': { $in: userIds } })
|
|
173
|
+
.exec()
|
|
174
|
+
.then((entities) => entities.map((e) => this.mapper.toDto(e)));
|
|
175
|
+
}
|
|
176
|
+
async getByIdPublic(id) {
|
|
177
|
+
const entity = await this.eogModel.findById(id).exec();
|
|
178
|
+
if (!entity) {
|
|
179
|
+
throw new common_1.NotFoundException('EntityOwnershipGroup');
|
|
180
|
+
}
|
|
181
|
+
return await this.mapper.toDto(entity);
|
|
182
|
+
}
|
|
183
|
+
async getById(id) {
|
|
184
|
+
return this.eogModel.findById(id).exec();
|
|
185
|
+
}
|
|
186
|
+
async searchAll(searchAndPagination, user) {
|
|
187
|
+
let s = await this.searchParams(searchAndPagination);
|
|
188
|
+
let sort;
|
|
189
|
+
if (searchAndPagination?.sortBy && searchAndPagination.sortRotation) {
|
|
190
|
+
sort = {};
|
|
191
|
+
sort[searchAndPagination.sortBy] = searchAndPagination.sortRotation;
|
|
192
|
+
}
|
|
193
|
+
return (await this.eogModel.find(s).sort(sort).exec()).map((a) => this.mapper.toDto(a));
|
|
194
|
+
}
|
|
195
|
+
async searchPagination(searchAndPagination, user) {
|
|
196
|
+
const page = searchAndPagination?.page || 0, size = searchAndPagination?.size || 10;
|
|
197
|
+
let s = await this.searchParams(searchAndPagination);
|
|
198
|
+
let sort;
|
|
199
|
+
if (searchAndPagination?.sortBy && searchAndPagination.sortRotation) {
|
|
200
|
+
sort = {};
|
|
201
|
+
sort[searchAndPagination.sortBy] = searchAndPagination.sortRotation;
|
|
202
|
+
}
|
|
203
|
+
return (await crud_base_1.MongooseSearchUtil.modelSearch(this.eogModel, size, page, sort, {
|
|
204
|
+
$match: s,
|
|
205
|
+
})).mapAsync((a) => this.mapper.toDto(a));
|
|
206
|
+
}
|
|
207
|
+
searchParams(searchAndPagination) {
|
|
208
|
+
const s = {};
|
|
209
|
+
if (searchAndPagination?.description) {
|
|
210
|
+
s.description = {
|
|
211
|
+
$regex: new RegExp(searchAndPagination.description, 'i'),
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
if (searchAndPagination?.name) {
|
|
215
|
+
s.name = {
|
|
216
|
+
$regex: new RegExp(searchAndPagination.name, 'i'),
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
if (searchAndPagination?.memberUserId) {
|
|
220
|
+
s['userCapabilities.userId'] = searchAndPagination.memberUserId;
|
|
221
|
+
}
|
|
222
|
+
return s;
|
|
223
|
+
}
|
|
224
|
+
searchByUserId(userId, requestedCapabilities) {
|
|
225
|
+
const capabilityFilter = requestedCapabilities?.length
|
|
226
|
+
? {
|
|
227
|
+
$or: requestedCapabilities.map((capabilities) => ({
|
|
228
|
+
'userCapabilities.groupCapabilities': { $all: capabilities },
|
|
229
|
+
})),
|
|
230
|
+
}
|
|
231
|
+
: {};
|
|
232
|
+
return this.eogModel
|
|
233
|
+
.find({
|
|
234
|
+
'userCapabilities.userId': userId,
|
|
235
|
+
...capabilityFilter,
|
|
236
|
+
})
|
|
237
|
+
.exec()
|
|
238
|
+
.then((entities) => entities.map((e) => this.mapper.toDto(e)));
|
|
239
|
+
}
|
|
240
|
+
async addUserCapability(groupId, userCapability) {
|
|
241
|
+
const group = await this.getById(groupId);
|
|
242
|
+
if (!group) {
|
|
243
|
+
throw new Error('EntityOwnershipGroup not found');
|
|
244
|
+
}
|
|
245
|
+
const user = await this.userServiceLocal.findById(userCapability.userId);
|
|
246
|
+
userCapability.userFullName = user?.name + ' ' + user?.surname;
|
|
247
|
+
if (group.userCapabilities?.some((uc) => uc.userId === userCapability.userId)) {
|
|
248
|
+
this.logger.debug('UserCapability already exists in group', groupId, userCapability);
|
|
249
|
+
return this.mapper.toDto(group);
|
|
250
|
+
}
|
|
251
|
+
group.userCapabilities = group.userCapabilities || [];
|
|
252
|
+
group.userCapabilities.push(userCapability);
|
|
253
|
+
await group.save();
|
|
254
|
+
return this.mapper.toDto(group);
|
|
255
|
+
}
|
|
256
|
+
async removeUserCapability(groupId, userId, currentUser) {
|
|
257
|
+
const group = await this.getById(groupId);
|
|
258
|
+
if (!group) {
|
|
259
|
+
throw new Error('EntityOwnershipGroup not found');
|
|
260
|
+
}
|
|
261
|
+
if (currentUser &&
|
|
262
|
+
!currentUser.roles.includes('ADMIN') &&
|
|
263
|
+
currentUser.id === userId) {
|
|
264
|
+
throw new common_1.UnauthorizedException(`User ${currentUser.id} can't remove themselves from group`);
|
|
265
|
+
}
|
|
266
|
+
const people = group.userCapabilities || [];
|
|
267
|
+
if (people.length === 1) {
|
|
268
|
+
throw new common_1.UnauthorizedException(`Member can't be removed as the only member.`);
|
|
269
|
+
}
|
|
270
|
+
const removedUserIsOwner = people
|
|
271
|
+
.find((a) => a.userId === userId)
|
|
272
|
+
?.groupCapabilities?.includes(users_common_2.Capability.OWNER);
|
|
273
|
+
const ownerCount = people.filter((a) => a.groupCapabilities?.includes(users_common_2.Capability.OWNER)).length;
|
|
274
|
+
if (removedUserIsOwner && ownerCount < 2) {
|
|
275
|
+
throw new common_1.UnauthorizedException(`Owner can't leave Entity Ownership Group ${groupId} as the only owner.`);
|
|
276
|
+
}
|
|
277
|
+
group.userCapabilities = group.userCapabilities?.filter((uc) => !(uc.userId === userId));
|
|
278
|
+
await this.saveUserCapabilitiesWithOptimisticLock(groupId, group);
|
|
279
|
+
}
|
|
280
|
+
async updateUserCapability(groupId, userCapability, currentUser) {
|
|
281
|
+
const group = await this.eogModel.findById(groupId);
|
|
282
|
+
if (!group) {
|
|
283
|
+
throw new Error('EntityOwnershipGroup not found');
|
|
284
|
+
}
|
|
285
|
+
if (currentUser &&
|
|
286
|
+
!currentUser.roles.includes('ADMIN') &&
|
|
287
|
+
currentUser.id === userCapability.userId) {
|
|
288
|
+
throw new common_1.UnauthorizedException(`User ${currentUser.id} can't edit their own capabilities`);
|
|
289
|
+
}
|
|
290
|
+
const index = group.userCapabilities?.findIndex((uc) => uc.userId === userCapability.userId);
|
|
291
|
+
if (index === undefined || index < 0) {
|
|
292
|
+
throw new Error('UserCapability not found in group');
|
|
293
|
+
}
|
|
294
|
+
group.userCapabilities[index].entityCapabilities =
|
|
295
|
+
userCapability.entityCapabilities;
|
|
296
|
+
group.userCapabilities[index].groupCapabilities =
|
|
297
|
+
userCapability.groupCapabilities;
|
|
298
|
+
await this.saveUserCapabilitiesWithOptimisticLock(groupId, group);
|
|
299
|
+
return this.mapper.toDto(group);
|
|
300
|
+
}
|
|
301
|
+
async saveUserCapabilitiesWithOptimisticLock(groupId, group) {
|
|
302
|
+
const expectedVersion = group.__v;
|
|
303
|
+
const updateResult = await this.eogModel.updateOne({
|
|
304
|
+
_id: groupId,
|
|
305
|
+
__v: expectedVersion,
|
|
306
|
+
}, {
|
|
307
|
+
$set: {
|
|
308
|
+
userCapabilities: group.userCapabilities,
|
|
309
|
+
},
|
|
310
|
+
$inc: {
|
|
311
|
+
__v: 1,
|
|
312
|
+
},
|
|
313
|
+
});
|
|
314
|
+
if (updateResult.modifiedCount === 0) {
|
|
315
|
+
throw new common_1.ConflictException(`Entity Ownership Group ${groupId} was modified concurrently. Please retry.`);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
async addUserCapabilityInvite(groupId, userCapability, currentUser) {
|
|
319
|
+
const group = await this.getById(groupId);
|
|
320
|
+
if (!group) {
|
|
321
|
+
throw new Error('EntityOwnershipGroup not found');
|
|
322
|
+
}
|
|
323
|
+
const userInvited = await this.userServiceLocal.findUserByLogin({
|
|
324
|
+
login: userCapability.userLogin,
|
|
325
|
+
password: '',
|
|
326
|
+
});
|
|
327
|
+
if (!userInvited) {
|
|
328
|
+
throw new Error('Invited user not found');
|
|
329
|
+
}
|
|
330
|
+
if (userInvited.id === currentUser.id) {
|
|
331
|
+
throw new common_1.UnauthorizedException(`User ${currentUser.id} can't give capabilities to themselves`);
|
|
332
|
+
}
|
|
333
|
+
const invitedByName = `${currentUser.name} ${currentUser.surname}`;
|
|
334
|
+
const name = group.name;
|
|
335
|
+
const emailTemplate = 'lotus-publisher-team-invitation';
|
|
336
|
+
const emailSubject = 'ubs-user-email-change-title';
|
|
337
|
+
if (group.userCapabilities?.some((uc) => uc.userId === userInvited.id)) {
|
|
338
|
+
this.logger.debug('UserCapability already exists in group', groupId, userCapability);
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
let existingInvite = await this.eogInvitationModel
|
|
342
|
+
.findOne({
|
|
343
|
+
entityOwnershipGroupId: groupId,
|
|
344
|
+
invitedUserName: userCapability.userLogin,
|
|
345
|
+
})
|
|
346
|
+
.exec();
|
|
347
|
+
const eogCapabilities = userCapability.entityCapabilities;
|
|
348
|
+
if (!existingInvite) {
|
|
349
|
+
existingInvite = new this.eogInvitationModel({
|
|
350
|
+
invitedUserName: `${userInvited.name} ${userInvited.surname}`,
|
|
351
|
+
invitedUserId: userInvited.id,
|
|
352
|
+
invitedByUserId: currentUser.id,
|
|
353
|
+
invitedByUserName: invitedByName,
|
|
354
|
+
entityOwnershipGroupId: groupId,
|
|
355
|
+
groupCapabilities: userCapability.capabilities,
|
|
356
|
+
entityCapabilities: this.eogCapabilitiesToEntity(eogCapabilities),
|
|
357
|
+
eogName: group.name,
|
|
358
|
+
eogId: group._id,
|
|
359
|
+
eogDescription: group.description,
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
await existingInvite.save();
|
|
363
|
+
await this.emailService.sendEmail(userInvited, emailSubject, emailTemplate, {
|
|
364
|
+
name,
|
|
365
|
+
invitedBy: invitedByName,
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
eogCapabilitiesToEntity(eogCapabilities) {
|
|
369
|
+
return eogCapabilities.map((ec) => ({
|
|
370
|
+
entityGroup: ec.entityGroup,
|
|
371
|
+
entityName: ec.entityName,
|
|
372
|
+
capabilities: ec.capabilities,
|
|
373
|
+
}));
|
|
374
|
+
}
|
|
375
|
+
async addUserCapabilityAcceptInvite(inviteId, currentUser) {
|
|
376
|
+
const invite = await this.eogInvitationModel.findOne({
|
|
377
|
+
_id: inviteId,
|
|
378
|
+
});
|
|
379
|
+
if (!invite) {
|
|
380
|
+
throw new Error('Invitation not found');
|
|
381
|
+
}
|
|
382
|
+
if (invite.invitedUserId !== currentUser.id) {
|
|
383
|
+
throw new Error('Invitation does not belong to the current user');
|
|
384
|
+
}
|
|
385
|
+
const group = await this.getById(invite.entityOwnershipGroupId);
|
|
386
|
+
if (!group) {
|
|
387
|
+
throw new Error('EntityOwnershipGroup not found');
|
|
388
|
+
}
|
|
389
|
+
const userCapability = {
|
|
390
|
+
userId: invite.invitedUserId,
|
|
391
|
+
entityCapabilities: invite.entityCapabilities?.map((ec) => ({
|
|
392
|
+
entityGroup: ec.entityGroup,
|
|
393
|
+
entityName: ec.entityName,
|
|
394
|
+
capabilities: ec.capabilities,
|
|
395
|
+
})),
|
|
396
|
+
userFullName: invite.invitedUserName,
|
|
397
|
+
groupCapabilities: invite.groupCapabilities,
|
|
398
|
+
};
|
|
399
|
+
await this.addUserCapability(group._id, userCapability);
|
|
400
|
+
await this.eogInvitationModel.deleteOne({ _id: invite._id }).exec();
|
|
401
|
+
await this.removeUserInEntityCapability(group, invite);
|
|
402
|
+
}
|
|
403
|
+
async removeUserInEntityCapability(group, invite) {
|
|
404
|
+
await this.eoModel
|
|
405
|
+
.updateMany({
|
|
406
|
+
entityOwnershipGroupId: group._id,
|
|
407
|
+
userCapabilities: {
|
|
408
|
+
$elemMatch: { userId: invite.invitedUserId },
|
|
409
|
+
},
|
|
410
|
+
}, {
|
|
411
|
+
$pull: {
|
|
412
|
+
userCapabilities: { userId: invite.invitedUserId },
|
|
413
|
+
},
|
|
414
|
+
})
|
|
415
|
+
.exec();
|
|
416
|
+
}
|
|
417
|
+
async removeInvitationAdmin(invitationId) {
|
|
418
|
+
await this.eogInvitationModel.findByIdAndDelete(invitationId);
|
|
419
|
+
}
|
|
420
|
+
async refuseUserCapabilityInvite(inviteId, currentUser) {
|
|
421
|
+
await this.eogInvitationModel.findOneAndDelete({
|
|
422
|
+
_id: inviteId,
|
|
423
|
+
invitedUserId: currentUser.id,
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
async fetchCurrentUserInvitations(currentUserId) {
|
|
427
|
+
return this.eogInvitationModel
|
|
428
|
+
.find({ invitedUserId: currentUserId })
|
|
429
|
+
.exec()
|
|
430
|
+
.then((invitations) => invitations.map((invite) => this.invitationToDto(invite)));
|
|
431
|
+
}
|
|
432
|
+
invitationToDto(invite) {
|
|
433
|
+
return {
|
|
434
|
+
entityCapabilities: this.eogEntityCapabilitiesToDto(invite),
|
|
435
|
+
userId: invite.invitedUserId,
|
|
436
|
+
groupCapabilities: invite.groupCapabilities,
|
|
437
|
+
userName: invite.invitedUserName,
|
|
438
|
+
invitedByUserId: invite.invitedByUserId,
|
|
439
|
+
invitedByUserName: invite.invitedByUserName,
|
|
440
|
+
invitationId: invite._id,
|
|
441
|
+
eogName: invite.eogName,
|
|
442
|
+
eogId: invite.eogId,
|
|
443
|
+
eogDescription: invite.eogDescription,
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
eogEntityCapabilitiesToDto(invite) {
|
|
447
|
+
return invite.entityCapabilities.map((ec) => ({
|
|
448
|
+
entityGroup: ec.entityGroup,
|
|
449
|
+
entityName: ec.entityName,
|
|
450
|
+
capabilities: ec.capabilities,
|
|
451
|
+
}));
|
|
452
|
+
}
|
|
453
|
+
async fetchUserCapabilityInvitations(id) {
|
|
454
|
+
return this.eogInvitationModel
|
|
455
|
+
.find({ entityOwnershipGroupId: id })
|
|
456
|
+
.exec()
|
|
457
|
+
.then((invitations) => invitations.map((invite) => this.invitationToDto(invite)));
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
exports.EntityOwnershipGroupService = EntityOwnershipGroupService;
|
|
461
|
+
exports.EntityOwnershipGroupService = EntityOwnershipGroupService = EntityOwnershipGroupService_1 = __decorate([
|
|
462
|
+
(0, common_1.Injectable)(),
|
|
463
|
+
__param(0, (0, mongoose_1.InjectModel)(users_entity_mongo_1.EntityOwnershipGroup.name)),
|
|
464
|
+
__param(1, (0, mongoose_1.InjectModel)(users_entity_mongo_2.EntityOwnershipGroupInvitation.name)),
|
|
465
|
+
__param(5, (0, mongoose_1.InjectModel)(users_entity_mongo_3.EntityOwnership.name)),
|
|
466
|
+
__metadata("design:paramtypes", [mongoose_2.Model,
|
|
467
|
+
mongoose_2.Model,
|
|
468
|
+
entity_ownership_group_mapper_1.EntityOwnershipGroupMapper,
|
|
469
|
+
user_service_1.UserService,
|
|
470
|
+
email_service_1.EmailService,
|
|
471
|
+
mongoose_2.Model])
|
|
472
|
+
], EntityOwnershipGroupService);
|
|
473
|
+
//# sourceMappingURL=entity-ownership-group.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-ownership-group.service.js","sourceRoot":"","sources":["../../../../../../libs/users-webservice/src/services/entity-ownership-group.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAiH;AACjH,+CAA+C;AAE/C,uCAAkD;AAClD,6DAA2E;AAC3E,yEAG0C;AAC1C,2FAAqF;AAarF,iDAA6C;AAC7C,yEAAkF;AAClF,6DAIoC;AACpC,mDAA+C;AAG/C,uDAA6D;AAG7D,yEAAmE;AAM5D,IAAM,2BAA2B,mCAAjC,MAAM,2BAA2B;IAMpC,YAEI,QAA6C,EAE7C,kBAAiE,EACzD,MAAkC,EAClC,gBAA6B,EAC7B,YAA0B,EAElC,OAAuC;QAP/B,aAAQ,GAAR,QAAQ,CAA6B;QAErC,uBAAkB,GAAlB,kBAAkB,CAAuC;QACzD,WAAM,GAAN,MAAM,CAA4B;QAClC,qBAAgB,GAAhB,gBAAgB,CAAa;QAC7B,iBAAY,GAAZ,YAAY,CAAc;QAE1B,YAAO,GAAP,OAAO,CAAwB;QAd1B,WAAM,GAAG,IAAI,eAAM,CAAC,6BAA2B,CAAC,IAAI,EAAE;YACnE,SAAS,EAAE,IAAI;SAClB,CAAC,CAAC;QAC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AO,EAAE,MAAM,CAAC,OAAO;YACvB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,cAAc,EAAE,MAAM,CAAC,cAAc;SACN,CAAC;IACxC,CAAC;IAEO,0BAA0B,CAC9B,MAAsC;QAEtC,OAAO,MAAM,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;YAC1C,WAAW,EAAE,EAAE,CAAC,WAAW;YAC3B,UAAU,EAAE,EAAE,CAAC,UAAU;YACzB,YAAY,EAAE,EAAE,CAAC,YAAY;SAChC,CAAC,CAAC,CAAC;IACR,CAAC;IAED,KAAK,CAAC,8BAA8B,CAChC,EAAU;QAEV,OAAO,IAAI,CAAC,kBAAkB;aACzB,IAAI,CAAC,EAAE,sBAAsB,EAAE,EAAE,EAAE,CAAC;aACpC,IAAI,EAAE;aACN,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAClB,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAC5D,CAAC;IACV,CAAC;CACJ,CAAA;AAtnBY,kEAA2B;sCAA3B,2BAA2B;IADvC,IAAA,mBAAU,GAAE;IAQJ,WAAA,IAAA,sBAAW,EAAC,yCAAoB,CAAC,IAAI,CAAC,CAAA;IAEtC,WAAA,IAAA,sBAAW,EAAC,mDAA8B,CAAC,IAAI,CAAC,CAAA;IAKhD,WAAA,IAAA,sBAAW,EAAC,oCAAe,CAAC,IAAI,CAAC,CAAA;qCANhB,gBAAK;QAEK,gBAAK;QACjB,0DAA0B;QAChB,0BAAW;QACf,4BAAY;QAEjB,gBAAK;GAfjB,2BAA2B,CAsnBvC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Model } from 'mongoose';
|
|
2
|
+
import { EntityOwnership } from '@ubs-platform/users-entity-mongo';
|
|
3
|
+
import { EntityOwnershipMapper } from '../mapper/entity-ownership.mapper';
|
|
4
|
+
import { EntityOwnershipDTO, EntityOwnershipInsertCapabiltyDTO, EntityOwnershipSearch, EntityOwnershipUserCheck, EntityOwnershipUserSearch, UserCapabilityDTO } from '@ubs-platform/users-common';
|
|
5
|
+
import { UserService } from './user.service';
|
|
6
|
+
import { EntityOwnershipGroup } from '@ubs-platform/users-entity-mongo';
|
|
7
|
+
import { Optional } from '@ubs-platform/crud-base-common/utils';
|
|
8
|
+
export declare class EntityOwnershipService {
|
|
9
|
+
private eoModel;
|
|
10
|
+
private eogModel;
|
|
11
|
+
private userService;
|
|
12
|
+
private mapper;
|
|
13
|
+
private readonly logger;
|
|
14
|
+
readonly APPLY_TK_LOTUS_MIGRATIONS: boolean;
|
|
15
|
+
constructor(eoModel: Model<EntityOwnership>, eogModel: Model<EntityOwnershipGroup>, userService: UserService, mapper: EntityOwnershipMapper);
|
|
16
|
+
onModuleInit(): Promise<void>;
|
|
17
|
+
private migrateCapabilities;
|
|
18
|
+
removeUserCapability(eo: EntityOwnershipUserCheck): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
19
|
+
private findEntitiesBySearchKeys;
|
|
20
|
+
private findUserCapabilityInEntity;
|
|
21
|
+
private findUserCapabilityInGroup;
|
|
22
|
+
private checkRoleOverride;
|
|
23
|
+
private findEntityOwnershipGroupsByUser;
|
|
24
|
+
edit(eoDto: EntityOwnershipDTO): Promise<void>;
|
|
25
|
+
insert(eoDto: EntityOwnershipDTO): Promise<void>;
|
|
26
|
+
insertUserCapability(oe: EntityOwnershipInsertCapabiltyDTO): Promise<void>;
|
|
27
|
+
private updateExistingUserCapability;
|
|
28
|
+
private addNewUserCapability;
|
|
29
|
+
hasInsertedUserCapability(eouc: EntityOwnershipUserCheck, checkRoleOverride: boolean): Promise<boolean>;
|
|
30
|
+
findInsertedUserCapability(entityOwnershipUserCheck: EntityOwnershipUserCheck, checkRoleOverride: boolean): Promise<Optional<UserCapabilityDTO>>;
|
|
31
|
+
private searchByUserRaw;
|
|
32
|
+
searchByUser(eo: EntityOwnershipUserSearch): Promise<EntityOwnershipDTO[]>;
|
|
33
|
+
searchByEntityIdsByEogroup(eo: EntityOwnershipUserSearch): Promise<string[]>;
|
|
34
|
+
hasOwnershipsByEogId(eogId: string): Promise<boolean>;
|
|
35
|
+
searchEntityIdsByUser(eo: EntityOwnershipUserSearch): Promise<string[]>;
|
|
36
|
+
search(sk: EntityOwnershipSearch): Promise<EntityOwnershipDTO[]>;
|
|
37
|
+
deleteOwnership(sk: EntityOwnershipSearch): Promise<void>;
|
|
38
|
+
private findRaw;
|
|
39
|
+
}
|