@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,347 @@
|
|
|
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 EntityOwnershipService_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.EntityOwnershipService = void 0;
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const mongoose_1 = require("mongoose");
|
|
19
|
+
const users_entity_mongo_1 = require("@ubs-platform/users-entity-mongo");
|
|
20
|
+
const users_common_1 = require("@ubs-platform/users-common");
|
|
21
|
+
const mongoose_2 = require("@nestjs/mongoose");
|
|
22
|
+
const entity_ownership_mapper_1 = require("../mapper/entity-ownership.mapper");
|
|
23
|
+
const users_common_2 = require("@ubs-platform/users-common");
|
|
24
|
+
const user_service_1 = require("./user.service");
|
|
25
|
+
const users_entity_mongo_2 = require("@ubs-platform/users-entity-mongo");
|
|
26
|
+
let EntityOwnershipService = EntityOwnershipService_1 = class EntityOwnershipService {
|
|
27
|
+
constructor(eoModel, eogModel, userService, mapper) {
|
|
28
|
+
this.eoModel = eoModel;
|
|
29
|
+
this.eogModel = eogModel;
|
|
30
|
+
this.userService = userService;
|
|
31
|
+
this.mapper = mapper;
|
|
32
|
+
this.logger = new common_1.Logger(EntityOwnershipService_1.name, {
|
|
33
|
+
timestamp: true,
|
|
34
|
+
});
|
|
35
|
+
this.APPLY_TK_LOTUS_MIGRATIONS = process.env['APPLY_TK_LOTUS_MIGRATIONS'] === undefined || process.env['APPLY_TK_LOTUS_MIGRATIONS'] === 'true';
|
|
36
|
+
}
|
|
37
|
+
async onModuleInit() {
|
|
38
|
+
this.logger.log('Starting capability migration...');
|
|
39
|
+
await this.migrateCapabilities();
|
|
40
|
+
this.logger.log('Capability migration completed.');
|
|
41
|
+
}
|
|
42
|
+
async migrateCapabilities() {
|
|
43
|
+
const allEntities = await this.eoModel.find({
|
|
44
|
+
'userCapabilities.capability': { $exists: true },
|
|
45
|
+
});
|
|
46
|
+
for (const entity of allEntities) {
|
|
47
|
+
let updated = false;
|
|
48
|
+
for (const userCap of entity.userCapabilities) {
|
|
49
|
+
if (userCap.capability && !userCap.capabilities?.length) {
|
|
50
|
+
userCap.capabilities = (0, users_common_1.migrateFromStringToCapability)(userCap.capability, this.APPLY_TK_LOTUS_MIGRATIONS);
|
|
51
|
+
userCap.capability = undefined;
|
|
52
|
+
updated = true;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (updated) {
|
|
56
|
+
entity.markModified('userCapabilities');
|
|
57
|
+
await entity.save();
|
|
58
|
+
this.logger.log(`Updated entity ${entity.entityGroup}/${entity.entityName}/${entity.entityId} to new capability structure.`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async removeUserCapability(eo) {
|
|
63
|
+
const searchKeys = {
|
|
64
|
+
entityGroup: eo.entityGroup,
|
|
65
|
+
entityId: eo.entityId,
|
|
66
|
+
entityName: eo.entityName,
|
|
67
|
+
};
|
|
68
|
+
const updateResult = await this.eoModel.updateOne(searchKeys, {
|
|
69
|
+
$pull: {
|
|
70
|
+
userCapabilities: {
|
|
71
|
+
userId: eo.userId,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
return updateResult;
|
|
76
|
+
}
|
|
77
|
+
async findEntitiesBySearchKeys(searchKeys) {
|
|
78
|
+
return await this.eoModel.find({ ...(searchKeys.entityId ? { entityId: searchKeys.entityId } : {}), entityGroup: searchKeys.entityGroup, entityName: searchKeys.entityName });
|
|
79
|
+
}
|
|
80
|
+
findUserCapabilityInEntity(entityOwnership, userId, requestedCapabilities) {
|
|
81
|
+
if (!entityOwnership?.userCapabilities?.length)
|
|
82
|
+
return null;
|
|
83
|
+
const found = entityOwnership.userCapabilities.find((uc) => uc.userId === userId && (0, users_common_2.hasCapabilityFromInnerArray)(uc.capabilities, requestedCapabilities));
|
|
84
|
+
return found ? { userId: found.userId, capabilities: found.capabilities } : null;
|
|
85
|
+
}
|
|
86
|
+
async findUserCapabilityInGroup(entityOwnership, userCheck) {
|
|
87
|
+
if (!entityOwnership?.entityOwnershipGroupId)
|
|
88
|
+
return null;
|
|
89
|
+
const ownerShipGroup = await this.eogModel.findOne({
|
|
90
|
+
_id: entityOwnership.entityOwnershipGroupId,
|
|
91
|
+
userCapabilities: {
|
|
92
|
+
$elemMatch: {
|
|
93
|
+
userId: userCheck.userId,
|
|
94
|
+
entityCapabilities: {
|
|
95
|
+
$elemMatch: {
|
|
96
|
+
entityGroup: userCheck.entityGroup,
|
|
97
|
+
entityName: userCheck.entityName,
|
|
98
|
+
...(userCheck.requestedCapabilities?.length ? {
|
|
99
|
+
$or: userCheck.requestedCapabilities.map((cap) => ({
|
|
100
|
+
capabilities: { $all: cap },
|
|
101
|
+
})),
|
|
102
|
+
} : {}),
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
if (!ownerShipGroup?.userCapabilities?.length)
|
|
109
|
+
return null;
|
|
110
|
+
const userCapability = ownerShipGroup.userCapabilities.find((uc) => (uc.userId === userCheck.userId)
|
|
111
|
+
&& uc.entityCapabilities.some((ec) => ec.entityGroup === userCheck.entityGroup
|
|
112
|
+
&& ec.entityName === userCheck.entityName
|
|
113
|
+
&& (0, users_common_2.hasCapabilityFromInnerArray)(ec.capabilities, userCheck.requestedCapabilities)));
|
|
114
|
+
if (!userCapability)
|
|
115
|
+
return null;
|
|
116
|
+
const entityCapabilityMatch = userCapability.entityCapabilities.find((ec) => userCheck.entityGroup === ec.entityGroup &&
|
|
117
|
+
userCheck.entityName === ec.entityName &&
|
|
118
|
+
(0, users_common_2.hasCapabilityFromInnerArray)(ec.capabilities, userCheck.requestedCapabilities));
|
|
119
|
+
return entityCapabilityMatch
|
|
120
|
+
? {
|
|
121
|
+
userId: userCapability.userId,
|
|
122
|
+
capabilities: entityCapabilityMatch.capabilities,
|
|
123
|
+
}
|
|
124
|
+
: null;
|
|
125
|
+
}
|
|
126
|
+
async checkRoleOverride(roleOverrides, userId, capabilities) {
|
|
127
|
+
if (!capabilities)
|
|
128
|
+
capabilities = [];
|
|
129
|
+
if (!roleOverrides?.length || !userId)
|
|
130
|
+
return null;
|
|
131
|
+
const user = await this.userService.findUserAuthBackend(userId);
|
|
132
|
+
if (!user?.roles?.length)
|
|
133
|
+
return null;
|
|
134
|
+
if (user.roles.includes('ADMIN')) {
|
|
135
|
+
return {
|
|
136
|
+
userId: user.id,
|
|
137
|
+
capabilities
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
const hasOverrideRole = user.roles.some((role) => roleOverrides.includes(role));
|
|
141
|
+
return hasOverrideRole
|
|
142
|
+
? {
|
|
143
|
+
userId: user.id,
|
|
144
|
+
capabilities: [users_common_2.Capability.VIEW, users_common_2.Capability.ADD, users_common_2.Capability.EDIT, users_common_2.Capability.DELETE]
|
|
145
|
+
}
|
|
146
|
+
: null;
|
|
147
|
+
}
|
|
148
|
+
async findEntityOwnershipGroupsByUser(eo) {
|
|
149
|
+
return await this.eogModel.find({
|
|
150
|
+
'userCapabilities.userId': eo.userId,
|
|
151
|
+
...(eo.requestedCapabilities
|
|
152
|
+
? {
|
|
153
|
+
'userCapabilities.entityCapabilities': {
|
|
154
|
+
$elemMatch: {
|
|
155
|
+
$or: eo.requestedCapabilities.map((cap) => ({
|
|
156
|
+
capabilities: { $all: cap },
|
|
157
|
+
})),
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
}
|
|
161
|
+
: {}),
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
async edit(eoDto) {
|
|
165
|
+
this.logger.debug('EO EDIT', eoDto.entityGroup, eoDto.entityId, eoDto.entityName);
|
|
166
|
+
const searchKeys = {
|
|
167
|
+
entityGroup: eoDto.entityGroup,
|
|
168
|
+
entityId: eoDto.entityId,
|
|
169
|
+
entityName: eoDto.entityName,
|
|
170
|
+
};
|
|
171
|
+
const foundEntities = await this.findEntitiesBySearchKeys(searchKeys);
|
|
172
|
+
let entity;
|
|
173
|
+
if (foundEntities.length > 0) {
|
|
174
|
+
entity = foundEntities[0];
|
|
175
|
+
this.mapper.toEntityEditWithMembers(entity, eoDto);
|
|
176
|
+
await entity.save();
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
throw new Error('EntityOwnership not found for edit.');
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
async insert(eoDto) {
|
|
183
|
+
this.logger.debug('EO INSERT', eoDto.entityGroup, eoDto.entityId, eoDto.entityName);
|
|
184
|
+
const searchKeys = {
|
|
185
|
+
entityGroup: eoDto.entityGroup,
|
|
186
|
+
entityId: eoDto.entityId,
|
|
187
|
+
entityName: eoDto.entityName,
|
|
188
|
+
};
|
|
189
|
+
const foundEntities = await this.findEntitiesBySearchKeys(searchKeys);
|
|
190
|
+
let entity;
|
|
191
|
+
if (foundEntities.length > 0) {
|
|
192
|
+
entity = foundEntities[0];
|
|
193
|
+
this.mapper.toEntityEdit(entity, eoDto);
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
entity = this.mapper.toEntity(eoDto);
|
|
197
|
+
}
|
|
198
|
+
await entity.save();
|
|
199
|
+
}
|
|
200
|
+
async insertUserCapability(oe) {
|
|
201
|
+
const hasRoleAlready = await this.findInsertedUserCapability(oe, false);
|
|
202
|
+
const searchKeys = {
|
|
203
|
+
entityGroup: oe.entityGroup,
|
|
204
|
+
entityId: oe.entityId,
|
|
205
|
+
entityName: oe.entityName,
|
|
206
|
+
};
|
|
207
|
+
if (hasRoleAlready?.userId) {
|
|
208
|
+
await this.updateExistingUserCapability(searchKeys, oe);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
await this.addNewUserCapability(searchKeys, oe);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
async updateExistingUserCapability(searchKeys, oe) {
|
|
215
|
+
const updateResult = await this.eoModel.updateOne({ ...searchKeys, 'userCapabilities.userId': oe.userId }, {
|
|
216
|
+
$set: {
|
|
217
|
+
'userCapabilities.$[related].capabilities': oe.capabilities,
|
|
218
|
+
},
|
|
219
|
+
}, { arrayFilters: [{ 'related.userId': oe.userId }] });
|
|
220
|
+
if (updateResult.modifiedCount === 0) {
|
|
221
|
+
this.logger.warn('User capability güncellenemedi:', oe);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
async addNewUserCapability(searchKeys, oe) {
|
|
225
|
+
const foundEntities = await this.findEntitiesBySearchKeys(searchKeys);
|
|
226
|
+
if (foundEntities.length > 0) {
|
|
227
|
+
const entity = foundEntities[0];
|
|
228
|
+
entity.userCapabilities.push({
|
|
229
|
+
capabilities: oe.capabilities,
|
|
230
|
+
userId: oe.userId,
|
|
231
|
+
});
|
|
232
|
+
await entity.save();
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
async hasInsertedUserCapability(eouc, checkRoleOverride) {
|
|
236
|
+
const found = await this.findInsertedUserCapability(eouc, checkRoleOverride);
|
|
237
|
+
return !!found;
|
|
238
|
+
}
|
|
239
|
+
async findInsertedUserCapability(entityOwnershipUserCheck, checkRoleOverride) {
|
|
240
|
+
const entityOwnership = (await this.findEntitiesBySearchKeys({
|
|
241
|
+
entityGroup: entityOwnershipUserCheck.entityGroup,
|
|
242
|
+
entityName: entityOwnershipUserCheck.entityName,
|
|
243
|
+
...(entityOwnershipUserCheck.entityId ? { entityId: entityOwnershipUserCheck.entityId } : {}),
|
|
244
|
+
}))[0];
|
|
245
|
+
if (!entityOwnership)
|
|
246
|
+
return null;
|
|
247
|
+
let found = this.findUserCapabilityInEntity(entityOwnership, entityOwnershipUserCheck.userId, entityOwnershipUserCheck.requestedCapabilities);
|
|
248
|
+
console.info('Found in entity:', found);
|
|
249
|
+
if (!found) {
|
|
250
|
+
found = await this.findUserCapabilityInGroup(entityOwnership, entityOwnershipUserCheck);
|
|
251
|
+
}
|
|
252
|
+
console.info('Found in group:', found);
|
|
253
|
+
if (!found && checkRoleOverride) {
|
|
254
|
+
const roleOverrides = entityOwnership.overriderRoles ||
|
|
255
|
+
(await this.eogModel.findById(entityOwnership.entityOwnershipGroupId))?.overriderRoles;
|
|
256
|
+
if (roleOverrides?.length) {
|
|
257
|
+
found = await this.checkRoleOverride(roleOverrides, entityOwnershipUserCheck.userId, entityOwnershipUserCheck.requestedCapabilities?.[0]);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
console.info('Found after role override check:', found);
|
|
261
|
+
this.logger.debug('Found capability:', found);
|
|
262
|
+
return found;
|
|
263
|
+
}
|
|
264
|
+
async searchByUserRaw(eo) {
|
|
265
|
+
const eogsByUser = await this.findEntityOwnershipGroupsByUser(eo);
|
|
266
|
+
this.logger.debug('EOGs by user:', eogsByUser.length);
|
|
267
|
+
const eos = await this.eoModel.find({
|
|
268
|
+
entityGroup: eo.entityGroup,
|
|
269
|
+
entityName: eo.entityName,
|
|
270
|
+
entityId: { $ne: null },
|
|
271
|
+
$or: [
|
|
272
|
+
{
|
|
273
|
+
userCapabilities: {
|
|
274
|
+
$elemMatch: {
|
|
275
|
+
userId: eo.userId,
|
|
276
|
+
...(eo.requestedCapabilities
|
|
277
|
+
? {
|
|
278
|
+
$or: eo.requestedCapabilities.map((cap) => ({
|
|
279
|
+
capabilities: { $all: cap },
|
|
280
|
+
})),
|
|
281
|
+
}
|
|
282
|
+
: {}),
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
...(eogsByUser.length
|
|
287
|
+
? [
|
|
288
|
+
{
|
|
289
|
+
entityOwnershipGroupId: {
|
|
290
|
+
$in: eogsByUser.map((eog) => eog._id),
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
]
|
|
294
|
+
: []),
|
|
295
|
+
],
|
|
296
|
+
});
|
|
297
|
+
return eos;
|
|
298
|
+
}
|
|
299
|
+
async searchByUser(eo) {
|
|
300
|
+
const entityOwnerships = await this.searchByUserRaw(eo);
|
|
301
|
+
return entityOwnerships.map((a) => this.mapper.toDto(a));
|
|
302
|
+
}
|
|
303
|
+
async searchByEntityIdsByEogroup(eo) {
|
|
304
|
+
if (!eo.entityOwnershipGroupId) {
|
|
305
|
+
throw new Error('entityOwnershipGroupId is required for this method.');
|
|
306
|
+
}
|
|
307
|
+
const eos = await this.eoModel.find({
|
|
308
|
+
entityGroup: eo.entityGroup,
|
|
309
|
+
entityName: eo.entityName,
|
|
310
|
+
entityId: { $ne: null },
|
|
311
|
+
entityOwnershipGroupId: eo.entityOwnershipGroupId,
|
|
312
|
+
});
|
|
313
|
+
return eos.map((a) => a.entityId?.toString());
|
|
314
|
+
}
|
|
315
|
+
async hasOwnershipsByEogId(eogId) {
|
|
316
|
+
const eos = await this.eoModel.find({
|
|
317
|
+
entityOwnershipGroupId: eogId,
|
|
318
|
+
});
|
|
319
|
+
return eos?.length > 0;
|
|
320
|
+
}
|
|
321
|
+
async searchEntityIdsByUser(eo) {
|
|
322
|
+
const entityOwnerships = await this.searchByUserRaw(eo);
|
|
323
|
+
return entityOwnerships.map((a) => a.entityId.toString());
|
|
324
|
+
}
|
|
325
|
+
async search(sk) {
|
|
326
|
+
const entities = await this.findEntitiesBySearchKeys(sk);
|
|
327
|
+
console.info('Found entities:', entities.length);
|
|
328
|
+
return entities.map((a) => this.mapper.toDto(a));
|
|
329
|
+
}
|
|
330
|
+
async deleteOwnership(sk) {
|
|
331
|
+
await this.eoModel.deleteOne(sk);
|
|
332
|
+
}
|
|
333
|
+
async findRaw(searchKeys) {
|
|
334
|
+
return this.findEntitiesBySearchKeys(searchKeys);
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
exports.EntityOwnershipService = EntityOwnershipService;
|
|
338
|
+
exports.EntityOwnershipService = EntityOwnershipService = EntityOwnershipService_1 = __decorate([
|
|
339
|
+
(0, common_1.Injectable)(),
|
|
340
|
+
__param(0, (0, mongoose_2.InjectModel)(users_entity_mongo_1.EntityOwnership.name)),
|
|
341
|
+
__param(1, (0, mongoose_2.InjectModel)(users_entity_mongo_2.EntityOwnershipGroup.name)),
|
|
342
|
+
__metadata("design:paramtypes", [mongoose_1.Model,
|
|
343
|
+
mongoose_1.Model,
|
|
344
|
+
user_service_1.UserService,
|
|
345
|
+
entity_ownership_mapper_1.EntityOwnershipMapper])
|
|
346
|
+
], EntityOwnershipService);
|
|
347
|
+
//# sourceMappingURL=entity-ownership.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-ownership.service.js","sourceRoot":"","sources":["../../../../../../libs/users-webservice/src/services/entity-ownership.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,uCAAiC;AACjC,yEAG0C;AAC1C,6DAA2E;AAC3E,+CAA+C;AAC/C,+EAA0E;AAC1E,6DAUoC;AACpC,iDAA6C;AAC7C,yEAAwE;AAIjE,IAAM,sBAAsB,8BAA5B,MAAM,sBAAsB;IAO/B,YAEI,OAAuC,EAEvC,QAA6C,EACrC,WAAwB,EACxB,MAA6B;QAJ7B,YAAO,GAAP,OAAO,CAAwB;QAE/B,aAAQ,GAAR,QAAQ,CAA6B;QACrC,gBAAW,GAAX,WAAW,CAAa;QACxB,WAAM,GAAN,MAAM,CAAuB;QAZxB,WAAM,GAAG,IAAI,eAAM,CAAC,wBAAsB,CAAC,IAAI,EAAE;YAC9D,SAAS,EAAE,IAAI;SAClB,CAAC,CAAC;QAEM,8BAAyB,GAAG,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,KAAK,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,KAAK,MAAM,CAAC;IAS/I,CAAC;IAEE,KAAK,CAAC,YAAY;QAErB,IAAI,CAAC,M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,CAAC,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;QACjD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACrD,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,EAAyB;QAClD,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IACrC,CAAC;IAGO,KAAK,CAAC,OAAO,CACjB,UAAiC;QAEjC,OAAO,IAAI,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAC;IACrD,CAAC;CACJ,CAAA;AArdY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,mBAAU,GAAE;IASJ,WAAA,IAAA,sBAAW,EAAC,oCAAe,CAAC,IAAI,CAAC,CAAA;IAEjC,WAAA,IAAA,sBAAW,EAAC,yCAAoB,CAAC,IAAI,CAAC,CAAA;qCADtB,gBAAK;QAEJ,gBAAK;QACF,0BAAW;QAChB,+CAAqB;GAbhC,sBAAsB,CAqdlC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Model } from 'mongoose';
|
|
2
|
+
import { PwResetRequest } from '@ubs-platform/users-entity-mongo';
|
|
3
|
+
import { UserService } from './user.service';
|
|
4
|
+
import { EmailService } from './email.service';
|
|
5
|
+
export declare class PasswordResetService {
|
|
6
|
+
private uservice;
|
|
7
|
+
private passwordResetModel;
|
|
8
|
+
private emailService;
|
|
9
|
+
constructor(uservice: UserService, passwordResetModel: Model<PwResetRequest>, emailService: EmailService);
|
|
10
|
+
has(id: any): Promise<boolean>;
|
|
11
|
+
handleCron(): Promise<void>;
|
|
12
|
+
insertNewRequest(username: string, origin?: string): Promise<void>;
|
|
13
|
+
approve(pwResetId: string, newPassword: string): Promise<void>;
|
|
14
|
+
private sendChangePwLink;
|
|
15
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.PasswordResetService = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const mongoose_1 = require("@nestjs/mongoose");
|
|
18
|
+
const mongoose_2 = require("mongoose");
|
|
19
|
+
const users_entity_mongo_1 = require("@ubs-platform/users-entity-mongo");
|
|
20
|
+
const user_service_1 = require("./user.service");
|
|
21
|
+
const email_service_1 = require("./email.service");
|
|
22
|
+
const schedule_1 = require("@nestjs/schedule");
|
|
23
|
+
let PasswordResetService = class PasswordResetService {
|
|
24
|
+
constructor(uservice, passwordResetModel, emailService) {
|
|
25
|
+
this.uservice = uservice;
|
|
26
|
+
this.passwordResetModel = passwordResetModel;
|
|
27
|
+
this.emailService = emailService;
|
|
28
|
+
}
|
|
29
|
+
async has(id) {
|
|
30
|
+
return ((await this.passwordResetModel.countDocuments({
|
|
31
|
+
_id: id,
|
|
32
|
+
expireAfter: {
|
|
33
|
+
$gt: new Date(),
|
|
34
|
+
},
|
|
35
|
+
})) > 0);
|
|
36
|
+
}
|
|
37
|
+
async handleCron() {
|
|
38
|
+
await this.passwordResetModel.deleteMany({
|
|
39
|
+
expireAfter: { $lt: new Date().toISOString() },
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
async insertNewRequest(username, origin) {
|
|
43
|
+
const EXPIRE_AFTER = 120;
|
|
44
|
+
const u = await this.uservice.findUserByLogin({
|
|
45
|
+
login: username,
|
|
46
|
+
password: '',
|
|
47
|
+
});
|
|
48
|
+
await this.passwordResetModel
|
|
49
|
+
.deleteMany({
|
|
50
|
+
$or: [
|
|
51
|
+
{
|
|
52
|
+
expireAfter: {
|
|
53
|
+
$lt: new Date(),
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
u?.id
|
|
57
|
+
? {
|
|
58
|
+
userId: u.id,
|
|
59
|
+
}
|
|
60
|
+
: null,
|
|
61
|
+
].filter((a) => a),
|
|
62
|
+
})
|
|
63
|
+
.exec();
|
|
64
|
+
if (u) {
|
|
65
|
+
console.info(u);
|
|
66
|
+
const exp = new Date();
|
|
67
|
+
exp.setMinutes(exp.getMinutes() + EXPIRE_AFTER);
|
|
68
|
+
let ech = new this.passwordResetModel();
|
|
69
|
+
ech.expireAfter = exp;
|
|
70
|
+
ech.userId = u.id;
|
|
71
|
+
ech = await ech.save();
|
|
72
|
+
this.sendChangePwLink(u, origin, ech._id);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
async approve(pwResetId, newPassword) {
|
|
76
|
+
const exist = await this.passwordResetModel.findOne({
|
|
77
|
+
_id: pwResetId,
|
|
78
|
+
expireAfter: {
|
|
79
|
+
$gt: new Date(),
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
console.info('Current email change refresh', exist);
|
|
83
|
+
if (exist) {
|
|
84
|
+
console.info(exist.userId);
|
|
85
|
+
await this.uservice.changePasswordForgor(exist.userId, newPassword);
|
|
86
|
+
await this.passwordResetModel.deleteOne({ _id: exist.id });
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
throw new common_1.HttpException('No records found', 404);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
sendChangePwLink(u, origin, echId) {
|
|
93
|
+
this.emailService.sendEmail(u, 'password-reset-short', 'ubs-pwreset', {
|
|
94
|
+
link: origin +
|
|
95
|
+
process.env['U_USERS_PW_RESET_URL']?.replace(':id', echId),
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
exports.PasswordResetService = PasswordResetService;
|
|
100
|
+
__decorate([
|
|
101
|
+
(0, schedule_1.Cron)('* */5 * * * *'),
|
|
102
|
+
__metadata("design:type", Function),
|
|
103
|
+
__metadata("design:paramtypes", []),
|
|
104
|
+
__metadata("design:returntype", Promise)
|
|
105
|
+
], PasswordResetService.prototype, "handleCron", null);
|
|
106
|
+
exports.PasswordResetService = PasswordResetService = __decorate([
|
|
107
|
+
(0, common_1.Injectable)(),
|
|
108
|
+
__param(1, (0, mongoose_1.InjectModel)(users_entity_mongo_1.PwResetRequest.name)),
|
|
109
|
+
__metadata("design:paramtypes", [user_service_1.UserService,
|
|
110
|
+
mongoose_2.Model,
|
|
111
|
+
email_service_1.EmailService])
|
|
112
|
+
], PasswordResetService);
|
|
113
|
+
//# sourceMappingURL=password-reset.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password-reset.service.js","sourceRoot":"","sources":["../../../../../../libs/users-webservice/src/services/password-reset.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAmE;AACnE,+CAA+C;AAC/C,uCAAiC;AAEjC,yEAAkE;AAClE,iDAA6C;AAM7C,mDAA+C;AAC/C,+CAAwC;AAGjC,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAC7B,YACY,QAAqB,EAErB,kBAAyC,EACzC,YAA0B;QAH1B,aAAQ,GAAR,QAAQ,CAAa;QAErB,uBAAkB,GAAlB,kBAAkB,CAAuB;QACzC,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AAC,KAAK,EAAE,KAAK,CAAC;SACjE,CAAC,CAAC;IACP,CAAC;CACJ,CAAA;AA7FY,oDAAoB;AAsBvB;IADL,IAAA,eAAI,EAAC,eAAe,CAAC;;;;sDAKrB;+BA1BQ,oBAAoB;IADhC,IAAA,mBAAU,GAAE;IAIJ,WAAA,IAAA,sBAAW,EAAC,mCAAc,CAAC,IAAI,CAAC,CAAA;qCADf,0BAAW;QAED,gBAAK;QACX,4BAAY;GAL7B,oBAAoB,CA6FhC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { UserDTO, UserCreateDTO, UserRegisterDTO } from '@ubs-platform/users-common';
|
|
2
|
+
import { User } from '@ubs-platform/users-entity-mongo';
|
|
3
|
+
import { Model } from 'mongoose';
|
|
4
|
+
export declare class UserCommonService {
|
|
5
|
+
private userModel;
|
|
6
|
+
constructor(userModel: Model<User>);
|
|
7
|
+
findByUsernameOrEmail(username: string, email: string): Promise<UserDTO[]>;
|
|
8
|
+
assertUserInfoValid(user: UserDTO | UserCreateDTO | UserRegisterDTO): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.UserCommonService = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const mongoose_1 = require("@nestjs/mongoose");
|
|
18
|
+
const users_common_1 = require("@ubs-platform/users-common");
|
|
19
|
+
const users_entity_mongo_1 = require("@ubs-platform/users-entity-mongo");
|
|
20
|
+
const mongoose_2 = require("mongoose");
|
|
21
|
+
const user_mapper_1 = require("../mapper/user.mapper");
|
|
22
|
+
let UserCommonService = class UserCommonService {
|
|
23
|
+
constructor(userModel) {
|
|
24
|
+
this.userModel = userModel;
|
|
25
|
+
}
|
|
26
|
+
async findByUsernameOrEmail(username, email) {
|
|
27
|
+
const us = await this.userModel.find({
|
|
28
|
+
$or: [{ username: username }, { primaryEmail: email }],
|
|
29
|
+
});
|
|
30
|
+
return user_mapper_1.UserMapper.toDtoList(us);
|
|
31
|
+
}
|
|
32
|
+
async assertUserInfoValid(user) {
|
|
33
|
+
if (!user || !user.username || !user.primaryEmail) {
|
|
34
|
+
throw new users_common_1.ErrorInformations(users_common_1.UBSUsersErrorConsts.EMPTY_DATA, 'One or More Required informations are empty.');
|
|
35
|
+
}
|
|
36
|
+
const userWithPrimaryMail = await this.findByUsernameOrEmail(user.username, user.primaryEmail);
|
|
37
|
+
if (userWithPrimaryMail.length) {
|
|
38
|
+
if (userWithPrimaryMail[0].username == user.username) {
|
|
39
|
+
throw new users_common_1.ErrorInformations(users_common_1.UBSUsersErrorConsts.EXIST_USERNAME, 'User with that login is exist.');
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
throw new users_common_1.ErrorInformations(users_common_1.UBSUsersErrorConsts.EXIST_PRIMARY_MAIL, 'User with that primary mail is exist.');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
exports.UserCommonService = UserCommonService;
|
|
48
|
+
exports.UserCommonService = UserCommonService = __decorate([
|
|
49
|
+
(0, common_1.Injectable)(),
|
|
50
|
+
__param(0, (0, mongoose_1.InjectModel)(users_entity_mongo_1.User.name)),
|
|
51
|
+
__metadata("design:paramtypes", [mongoose_2.Model])
|
|
52
|
+
], UserCommonService);
|
|
53
|
+
//# sourceMappingURL=user-common.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-common.service.js","sourceRoot":"","sources":["../../../../../../libs/users-webservice/src/services/user-common.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,+CAA+C;AAC/C,6DAMoC;AACpC,yEAAwD;AAExD,uCAAiC;AACjC,uDAAmD;AAE5C,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC1B,YAA4C,SAAsB;QAAtB,cAAS,GAAT,SAAS,CAAa;IAAG,CAAC;IAEtE,KAAK,CAAC,qBAAqB,CACvB,QAAgB,EAChB,KAAa;QAEb,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;YACjC,GAAG,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;SACzD,CAAC,CAAC;QACH,OAAO,wBAAU,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IACpC,CAAC;IAQD,KAAK,CAAC,mBAAmB,CAAC,IAA+C;QACrE,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YAChD,MAAM,IAAI,gCAAiB,CACvB,kCAAmB,CAAC,UAAU,EAC9B,8CAA8C,CACjD,CAAC;QACN,CAAC;QAED,MAAM,mBAAmB,GAAG,MAAM,IAAI,CAAC,qBAAqB,CACxD,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,YAAY,CACpB,CAAC;QACF,IAAI,mBAAmB,CAAC,MAAM,EAAE,CAAC;YAC7B,IAAI,mBAAmB,CAAC,CAAC,CAAC,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACnD,MAAM,IAAI,gCAAiB,CACvB,kCAAmB,CAAC,cAAc,EAClC,gCAAgC,CACnC,CAAC;YACN,CAAC;iBAAM,CAAC;gBACJ,MAAM,IAAI,gCAAiB,CACvB,kCAAmB,CAAC,kBAAkB,EACtC,uCAAuC,CAC1C,CAAC;YACN,CAAC;QACL,CAAC;IACL,CAAC;CACJ,CAAA;AA7CY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;IAEI,WAAA,IAAA,sBAAW,EAAC,yBAAI,CAAC,IAAI,CAAC,CAAA;qCAAoB,gBAAK;GADnD,iBAAiB,CA6C7B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { EmailService } from './email.service';
|
|
2
|
+
import { UserCandiate } from '@ubs-platform/users-entity-mongo';
|
|
3
|
+
import { Model } from 'mongoose';
|
|
4
|
+
import { UserRegisterDTO } from '@ubs-platform/users-common';
|
|
5
|
+
import { UserCommonService } from './user-common.service';
|
|
6
|
+
import { UserService } from './user.service';
|
|
7
|
+
export declare class UserRegisterService {
|
|
8
|
+
private userCandiateModel;
|
|
9
|
+
private userService;
|
|
10
|
+
private emailService;
|
|
11
|
+
private userCommon;
|
|
12
|
+
constructor(userCandiateModel: Model<UserCandiate>, userService: UserService, emailService: EmailService, userCommon: UserCommonService);
|
|
13
|
+
handleCron(): Promise<void>;
|
|
14
|
+
sendRegisteredEmail(u: UserCandiate, key: string, origin?: string): Promise<void>;
|
|
15
|
+
enableUser(activationKey: string): Promise<void>;
|
|
16
|
+
renewOrCheckOld(id?: string): Promise<UserRegisterDTO>;
|
|
17
|
+
register(uregister: UserRegisterDTO, origin: string): Promise<UserRegisterDTO>;
|
|
18
|
+
private setExpireDate;
|
|
19
|
+
assertUserInfoValid(uregister: UserRegisterDTO): Promise<void>;
|
|
20
|
+
}
|