gemcap-be-common 1.3.187 → 1.4.1
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/db/collaterals.db.d.ts +1 -1
- package/interfaces/auth-user.interface.d.ts +21 -0
- package/interfaces/auth-user.interface.ts +22 -0
- package/models/AvailabilitySigns.model.d.ts +3 -3
- package/models/AvailabilitySigns.model.ts +3 -3
- package/models/ReceivableAvailability.model.d.ts +32 -32
- package/models/ReceivableAvailability.model.ts +2 -2
- package/models/User.model.d.ts +3 -3
- package/models/User.model.ts +3 -3
- package/models/_index.d.ts +3 -3
- package/package.json +1 -1
- package/services/availability.service.d.ts +5 -5
- package/services/availability.service.ts +5 -5
- package/services/borrowers.db.d.ts +1 -1
- package/services/borrowers.db.js +1 -1
- package/services/borrowers.db.ts +2 -2
- package/services/borrowers.service.d.ts +5 -4
- package/services/borrowers.service.js +8 -5
- package/services/borrowers.service.ts +9 -5
- package/services/compliance-borrowers.service.d.ts +3 -3
- package/services/compliance-borrowers.service.ts +2 -2
- package/services/loan-payments.service.d.ts +3 -1
- package/services/loan-payments.service.js +5 -4
- package/services/loan-payments.service.ts +4 -3
- package/services/nodemailer.service.d.ts +0 -2
- package/services/nodemailer.service.js +0 -28
- package/services/nodemailer.service.ts +0 -35
- package/services/signs.service.d.ts +4 -4
- package/services/signs.service.js +2 -4
- package/services/signs.service.ts +8 -11
- package/services/uploads.service.d.ts +3 -1
- package/services/uploads.service.js +4 -3
- package/services/uploads.service.ts +3 -2
- package/services/users.service.d.ts +15 -137
- package/services/users.service.js +81 -349
- package/services/users.service.ts +88 -380
- package/tsconfig.tsbuildinfo +1 -1
- package/interfaces/keycloak-role.interface.d.ts +0 -14
- package/interfaces/keycloak-role.interface.ts +0 -16
- package/interfaces/keycloak-user.interface.d.ts +0 -31
- package/interfaces/keycloak-user.interface.js +0 -2
- package/interfaces/keycloak-user.interface.ts +0 -30
- /package/interfaces/{keycloak-role.interface.js → auth-user.interface.js} +0 -0
|
@@ -16,7 +16,6 @@ const collaterals_db_1 = require("../db/collaterals.db");
|
|
|
16
16
|
const LoanTransaction_model_1 = require("../models/LoanTransaction.model");
|
|
17
17
|
const LoanProducts_model_1 = require("../models/LoanProducts.model");
|
|
18
18
|
const Borrower_model_1 = require("../models/Borrower.model");
|
|
19
|
-
const User_model_1 = require("../models/User.model");
|
|
20
19
|
const LoanPayment_model_1 = require("../models/LoanPayment.model");
|
|
21
20
|
exports.paymentOrder = [
|
|
22
21
|
loan_charge_type_enum_1.ELoanChargeType.RECOVERABLE,
|
|
@@ -40,7 +39,8 @@ class LoanPaymentsService {
|
|
|
40
39
|
loanTransactionsService;
|
|
41
40
|
lockService;
|
|
42
41
|
termLoanService;
|
|
43
|
-
|
|
42
|
+
usersService;
|
|
43
|
+
constructor(redisClient, borrowersDB, financialComplianceService, loanChargesService, loanProductsService, loanStatementBalanceService, getLoanStatementService, loanStatementStatusService, loanTransactionsService, lockService, termLoanService, usersService) {
|
|
44
44
|
this.redisClient = redisClient;
|
|
45
45
|
this.borrowersDB = borrowersDB;
|
|
46
46
|
this.financialComplianceService = financialComplianceService;
|
|
@@ -52,6 +52,7 @@ class LoanPaymentsService {
|
|
|
52
52
|
this.loanTransactionsService = loanTransactionsService;
|
|
53
53
|
this.lockService = lockService;
|
|
54
54
|
this.termLoanService = termLoanService;
|
|
55
|
+
this.usersService = usersService;
|
|
55
56
|
}
|
|
56
57
|
async getLoanPayment(paymentId) {
|
|
57
58
|
return LoanPayment_model_1.LoanPaymentModel.findById(paymentId).lean();
|
|
@@ -399,7 +400,7 @@ class LoanPaymentsService {
|
|
|
399
400
|
}
|
|
400
401
|
}
|
|
401
402
|
async getExpectedPayments(userId) {
|
|
402
|
-
const user = await
|
|
403
|
+
const user = await this.usersService.getUserById(userId);
|
|
403
404
|
if (!user) {
|
|
404
405
|
return [];
|
|
405
406
|
}
|
|
@@ -429,7 +430,7 @@ class LoanPaymentsService {
|
|
|
429
430
|
return { message: 'Incorrect list of borrowers IDs' };
|
|
430
431
|
}
|
|
431
432
|
await this.redisClient.set(CALCULATION_VAR, 1);
|
|
432
|
-
const user = await
|
|
433
|
+
const user = await this.usersService.getUserById(userId);
|
|
433
434
|
if (!user) {
|
|
434
435
|
return { message: 'Cannot find user with this id' };
|
|
435
436
|
}
|
|
@@ -21,7 +21,6 @@ import {
|
|
|
21
21
|
} from '../models/LoanTransaction.model';
|
|
22
22
|
import { LoanProduct } from '../models/LoanProducts.model';
|
|
23
23
|
import { BorrowerModel } from '../models/Borrower.model';
|
|
24
|
-
import { UserModel } from '../models/User.model';
|
|
25
24
|
import {
|
|
26
25
|
ICombinedPayment,
|
|
27
26
|
ILoanPaymentDoc,
|
|
@@ -40,6 +39,7 @@ import { LoanStatementStatusService } from './loan-statement-status.service';
|
|
|
40
39
|
import { LoanTransactionsService } from './loan-transactions.service';
|
|
41
40
|
import { TermLoanService } from './term-loan.service';
|
|
42
41
|
import { LockService } from './lock.service';
|
|
42
|
+
import { UsersService } from './users.service';
|
|
43
43
|
|
|
44
44
|
export const paymentOrder = [
|
|
45
45
|
ELoanChargeType.RECOVERABLE,
|
|
@@ -66,6 +66,7 @@ export class LoanPaymentsService {
|
|
|
66
66
|
private readonly loanTransactionsService: LoanTransactionsService,
|
|
67
67
|
private readonly lockService: LockService,
|
|
68
68
|
private readonly termLoanService: TermLoanService,
|
|
69
|
+
private readonly usersService: UsersService,
|
|
69
70
|
) {
|
|
70
71
|
}
|
|
71
72
|
|
|
@@ -446,7 +447,7 @@ export class LoanPaymentsService {
|
|
|
446
447
|
}
|
|
447
448
|
|
|
448
449
|
async getExpectedPayments(userId: string) {
|
|
449
|
-
const user = await
|
|
450
|
+
const user = await this.usersService.getUserById(userId);
|
|
450
451
|
if (!user) {
|
|
451
452
|
return [];
|
|
452
453
|
}
|
|
@@ -480,7 +481,7 @@ export class LoanPaymentsService {
|
|
|
480
481
|
}
|
|
481
482
|
|
|
482
483
|
await this.redisClient.set(CALCULATION_VAR, 1);
|
|
483
|
-
const user = await
|
|
484
|
+
const user = await this.usersService.getUserById(userId);
|
|
484
485
|
if (!user) {
|
|
485
486
|
return { message: 'Cannot find user with this id' };
|
|
486
487
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Buffer } from 'buffer';
|
|
3
3
|
import { IMulterFile } from '../interfaces/multer.interface';
|
|
4
|
-
import { IKeycloakUser } from '../interfaces/keycloak-user.interface';
|
|
5
4
|
import { IEmail } from '../interfaces/email.interface';
|
|
6
5
|
import { IFinancialComplianceBorrowerDocumentWithMails } from '../models/FinancialComplianceBorrower.model';
|
|
7
6
|
import { FileManagerService } from './file-manager.service';
|
|
@@ -65,7 +64,6 @@ export declare class NodemailerService {
|
|
|
65
64
|
getSignatureAsync(senderType: ESenderType, organizationSubfolder?: string): Promise<string>;
|
|
66
65
|
collectItemsAndNotify(borrowerId: string): Promise<void>;
|
|
67
66
|
sendEmailNotification(email: EmailWithItems, borrowerId: string): Promise<void>;
|
|
68
|
-
sendPasswordEmail(user: IKeycloakUser, password: string): Promise<void>;
|
|
69
67
|
sendDailyUpdates(): Promise<void>;
|
|
70
68
|
sendSimpleNotificationMail(email: IEmail): Promise<void>;
|
|
71
69
|
sendFinancialExternal(email: IEmail, organizationId: string, stopFunding?: boolean): Promise<void>;
|
|
@@ -239,34 +239,6 @@ class NodemailerService {
|
|
|
239
239
|
}
|
|
240
240
|
});
|
|
241
241
|
}
|
|
242
|
-
async sendPasswordEmail(user, password) {
|
|
243
|
-
fs.readFile(path_1.default.resolve(__dirname, '../public/emails', 'password-reset.html'), 'utf8', async (error, data) => {
|
|
244
|
-
if (error) {
|
|
245
|
-
console.error({ error });
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
const signature = await this.getSignatureAsync(ESenderType.REGULAR);
|
|
249
|
-
const replacedData = data
|
|
250
|
-
.replace('${username}', user.username)
|
|
251
|
-
.replace('${password}', password.toString())
|
|
252
|
-
.replace('${signature}', signature);
|
|
253
|
-
try {
|
|
254
|
-
this.transporter.sendMail({
|
|
255
|
-
from: this.getSender(ESenderType.REGULAR),
|
|
256
|
-
to: user.email,
|
|
257
|
-
bcc: this.config.hiddenRecipient,
|
|
258
|
-
subject: `Welcome to ${this.config.appTitle}`,
|
|
259
|
-
text: 'non-html',
|
|
260
|
-
html: replacedData,
|
|
261
|
-
}, async (err, info) => {
|
|
262
|
-
await this.senderHandler(err, info);
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
catch (e) {
|
|
266
|
-
this.sentryService.catchErrorBySentry(null, e);
|
|
267
|
-
}
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
242
|
async sendDailyUpdates() {
|
|
271
243
|
fs.readFile(path_1.default.resolve(__dirname, '../public/emails', 'daily-updates.html'), 'utf8', async (error, data) => {
|
|
272
244
|
if (error) {
|
|
@@ -5,7 +5,6 @@ import nodemailer from 'nodemailer';
|
|
|
5
5
|
import { Buffer } from 'buffer';
|
|
6
6
|
|
|
7
7
|
import { IMulterFile } from '../interfaces/multer.interface';
|
|
8
|
-
import { IKeycloakUser } from '../interfaces/keycloak-user.interface';
|
|
9
8
|
import { IEmail } from '../interfaces/email.interface';
|
|
10
9
|
import { ELoanTypes } from '../enums/loan-types.enum';
|
|
11
10
|
import { Organization } from '../models/Organization.model';
|
|
@@ -268,40 +267,6 @@ export class NodemailerService {
|
|
|
268
267
|
});
|
|
269
268
|
}
|
|
270
269
|
|
|
271
|
-
async sendPasswordEmail(user: IKeycloakUser, password: string) {
|
|
272
|
-
fs.readFile(
|
|
273
|
-
path.resolve(__dirname, '../public/emails', 'password-reset.html'),
|
|
274
|
-
'utf8',
|
|
275
|
-
async (error, data) => {
|
|
276
|
-
if (error) {
|
|
277
|
-
console.error({ error });
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
const signature = await this.getSignatureAsync(ESenderType.REGULAR);
|
|
282
|
-
|
|
283
|
-
const replacedData = data
|
|
284
|
-
.replace('${username}', user.username)
|
|
285
|
-
.replace('${password}', password.toString())
|
|
286
|
-
.replace('${signature}', signature);
|
|
287
|
-
|
|
288
|
-
try {
|
|
289
|
-
this.transporter.sendMail({
|
|
290
|
-
from: this.getSender(ESenderType.REGULAR),
|
|
291
|
-
to: user.email,
|
|
292
|
-
bcc: this.config.hiddenRecipient,
|
|
293
|
-
subject: `Welcome to ${this.config.appTitle}`,
|
|
294
|
-
text: 'non-html',
|
|
295
|
-
html: replacedData,
|
|
296
|
-
}, async (err, info) => {
|
|
297
|
-
await this.senderHandler(err, info);
|
|
298
|
-
});
|
|
299
|
-
} catch (e) {
|
|
300
|
-
this.sentryService.catchErrorBySentry(null, e);
|
|
301
|
-
}
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
|
|
305
270
|
async sendDailyUpdates() {
|
|
306
271
|
fs.readFile(
|
|
307
272
|
path.resolve(__dirname, '../public/emails', 'daily-updates.html'),
|
|
@@ -24,16 +24,16 @@
|
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import mongoose, { Document } from 'mongoose';
|
|
26
26
|
import { IResult } from '../interfaces/result.interface';
|
|
27
|
-
import {
|
|
27
|
+
import { IUserLegacyDoc } from '../models/User.model';
|
|
28
28
|
import { IAvailabilitySignView } from '../models/AvailabilitySigns.model';
|
|
29
29
|
import { IBBCDateDoc } from '../models/BBCDate.model';
|
|
30
30
|
import { IBorrowerDocument } from '../models/Borrower.model';
|
|
31
|
-
import { IKeycloakUser } from '../interfaces/keycloak-user.interface';
|
|
32
31
|
import { IPaginatorOptions } from '../interfaces/collaterals.interface';
|
|
33
32
|
import { UsersService } from './users.service';
|
|
34
33
|
import { LoanTransactionsService } from './loan-transactions.service';
|
|
35
34
|
import { LockService } from './lock.service';
|
|
36
35
|
import { LoanStatementService } from './loan-statement.service';
|
|
36
|
+
import { IUser } from '../interfaces/auth-user.interface';
|
|
37
37
|
export interface IBBCDateWithBorrower extends Document {
|
|
38
38
|
borrowerId: IBorrowerDocument;
|
|
39
39
|
bbcDate: Date;
|
|
@@ -49,12 +49,12 @@ export declare class SignsService {
|
|
|
49
49
|
private readonly loanStatementService;
|
|
50
50
|
private readonly usersService;
|
|
51
51
|
constructor(lockService: LockService, loanTransactionsService: LoanTransactionsService, loanStatementService: LoanStatementService, usersService: UsersService);
|
|
52
|
-
keyCloakUsers:
|
|
52
|
+
keyCloakUsers: IUser[];
|
|
53
53
|
fulfillUserList(): Promise<void>;
|
|
54
54
|
clearUserList(): void;
|
|
55
55
|
getAvailabilitySigns(bbcDateId: string): Promise<IAvailabilitySignView>;
|
|
56
56
|
revokeAvailability(bbcDateId: string, userId: string, userIdRevoked: string): Promise<void>;
|
|
57
|
-
signAvailability(bbcDateId: string, user:
|
|
57
|
+
signAvailability(bbcDateId: string, user: IUserLegacyDoc): Promise<IResult>;
|
|
58
58
|
isBBCLocked(bbcDateId: string): Promise<boolean>;
|
|
59
59
|
getLatestSignedBBCDate(borrowerId: string, date?: Date): Promise<IBBCDateDoc>;
|
|
60
60
|
getSavedData(bbcDateId: string): Promise<any>;
|
|
@@ -34,8 +34,7 @@ class SignsService {
|
|
|
34
34
|
}
|
|
35
35
|
keyCloakUsers = null;
|
|
36
36
|
async fulfillUserList() {
|
|
37
|
-
|
|
38
|
-
this.keyCloakUsers = await this.usersService.getUserList(access_token);
|
|
37
|
+
this.keyCloakUsers = await this.usersService.getUserList();
|
|
39
38
|
}
|
|
40
39
|
clearUserList() {
|
|
41
40
|
this.keyCloakUsers = null;
|
|
@@ -53,8 +52,7 @@ class SignsService {
|
|
|
53
52
|
const availabilitySigns = availabilitiesSigns[0];
|
|
54
53
|
let keyCloakUsers = this.keyCloakUsers;
|
|
55
54
|
if (!keyCloakUsers) {
|
|
56
|
-
|
|
57
|
-
keyCloakUsers = await this.usersService.getUserList(access_token);
|
|
55
|
+
keyCloakUsers = await this.usersService.getUserList();
|
|
58
56
|
}
|
|
59
57
|
availabilitySigns.signs = availabilitySigns.signs.reduce((acc, userSign) => {
|
|
60
58
|
if (!userSign.userSigned) {
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
getAvailabilitySigns,
|
|
9
9
|
updateAvailabilitySigns,
|
|
10
10
|
} from '../db/availability.db';
|
|
11
|
-
import {
|
|
11
|
+
import { IUserLegacyDoc } from '../models/User.model';
|
|
12
12
|
import {
|
|
13
13
|
AvailabilitySignsModel,
|
|
14
14
|
IAvailabilitySignItem,
|
|
@@ -21,15 +21,14 @@ import { getOlderBBCDates } from '../db/bbcDates.db';
|
|
|
21
21
|
import { ELogActionType, ELogType } from '../models/UserLog.model';
|
|
22
22
|
import { createLog, ICreateLogParams } from '../db/user-logs.db';
|
|
23
23
|
import { IBorrowerDocument } from '../models/Borrower.model';
|
|
24
|
-
import { IKeycloakUser } from '../interfaces/keycloak-user.interface';
|
|
25
24
|
import { IPaginatorOptions } from '../interfaces/collaterals.interface';
|
|
26
25
|
import { ITEMS_PAGINATION } from '../db/collaterals.db';
|
|
27
26
|
import { UsersService } from './users.service';
|
|
28
|
-
|
|
29
27
|
import { AvailabilitySignedData } from '../models/AvilabilitySignedData.model';
|
|
30
28
|
import { LoanTransactionsService } from './loan-transactions.service';
|
|
31
29
|
import { LockService } from './lock.service';
|
|
32
30
|
import { LoanStatementService } from './loan-statement.service';
|
|
31
|
+
import { IUser } from '../interfaces/auth-user.interface';
|
|
33
32
|
|
|
34
33
|
export interface IBBCDateWithBorrower extends Document {
|
|
35
34
|
borrowerId: IBorrowerDocument;
|
|
@@ -52,11 +51,10 @@ export class SignsService {
|
|
|
52
51
|
) {
|
|
53
52
|
}
|
|
54
53
|
|
|
55
|
-
keyCloakUsers:
|
|
54
|
+
keyCloakUsers: IUser[] = null;
|
|
56
55
|
|
|
57
56
|
async fulfillUserList() {
|
|
58
|
-
|
|
59
|
-
this.keyCloakUsers = await this.usersService.getUserList(access_token);
|
|
57
|
+
this.keyCloakUsers = await this.usersService.getUserList();
|
|
60
58
|
}
|
|
61
59
|
|
|
62
60
|
clearUserList() {
|
|
@@ -76,8 +74,7 @@ export class SignsService {
|
|
|
76
74
|
const availabilitySigns = availabilitiesSigns[0];
|
|
77
75
|
let keyCloakUsers = this.keyCloakUsers;
|
|
78
76
|
if (!keyCloakUsers) {
|
|
79
|
-
|
|
80
|
-
keyCloakUsers = await this.usersService.getUserList(access_token);
|
|
77
|
+
keyCloakUsers = await this.usersService.getUserList();
|
|
81
78
|
}
|
|
82
79
|
availabilitySigns.signs = availabilitySigns.signs.reduce((acc, userSign) => {
|
|
83
80
|
if (!userSign.userSigned) {
|
|
@@ -88,14 +85,14 @@ export class SignsService {
|
|
|
88
85
|
userSign.userSigned.firstName = foundUserSigned.firstName;
|
|
89
86
|
userSign.userSigned.lastName = foundUserSigned.lastName;
|
|
90
87
|
}
|
|
91
|
-
userSign.userSigned = (_.pick(userSign.userSigned, ['_id', 'firstName', 'lastName'])) as
|
|
88
|
+
userSign.userSigned = (_.pick(userSign.userSigned, ['_id', 'firstName', 'lastName'])) as IUserLegacyDoc;
|
|
92
89
|
if (userSign.userRevoked) {
|
|
93
90
|
const foundUserRevoked = keyCloakUsers.find((user) => user.id === userSign.userRevoked.keycloakUserId);
|
|
94
91
|
if (foundUserRevoked) {
|
|
95
92
|
userSign.userRevoked.firstName = foundUserRevoked.firstName;
|
|
96
93
|
userSign.userRevoked.lastName = foundUserRevoked.lastName;
|
|
97
94
|
}
|
|
98
|
-
userSign.userRevoked = (_.pick(userSign.userRevoked, ['_id', 'firstName', 'lastName'])) as
|
|
95
|
+
userSign.userRevoked = (_.pick(userSign.userRevoked, ['_id', 'firstName', 'lastName'])) as IUserLegacyDoc;
|
|
99
96
|
}
|
|
100
97
|
return [...acc, _.pick(userSign, ['userSigned', 'signedAt', 'userRevoked', 'revokedAt'])];
|
|
101
98
|
}, []);
|
|
@@ -115,7 +112,7 @@ export class SignsService {
|
|
|
115
112
|
await updateAvailabilitySigns(bbcDateId, updatedSigns);
|
|
116
113
|
}
|
|
117
114
|
|
|
118
|
-
async signAvailability(bbcDateId: string, user:
|
|
115
|
+
async signAvailability(bbcDateId: string, user: IUserLegacyDoc): Promise<IResult> {
|
|
119
116
|
const newSign = <IAvailabilitySignItem>{ userSignedId: user._id, signedAt: new Date() };
|
|
120
117
|
return await addAvailabilitySign(bbcDateId, newSign);
|
|
121
118
|
}
|
|
@@ -37,6 +37,7 @@ import { QuickbooksService } from './quickbooks.service';
|
|
|
37
37
|
import { UserLogsService } from './user-logs.service';
|
|
38
38
|
import { LockService } from './lock.service';
|
|
39
39
|
import { BorrowersDB } from './borrowers.db';
|
|
40
|
+
import { UsersService } from './users.service';
|
|
40
41
|
interface IMappedColumns {
|
|
41
42
|
[columnName: string]: number;
|
|
42
43
|
}
|
|
@@ -73,7 +74,8 @@ export declare class UploadsService {
|
|
|
73
74
|
private readonly getLockService;
|
|
74
75
|
private readonly userLogsService;
|
|
75
76
|
private readonly borrowersDB;
|
|
76
|
-
|
|
77
|
+
private readonly usersService;
|
|
78
|
+
constructor(rootDir: string, bankUploadedTransactionsService: BankUploadedTransactionsService, getCollateralsService: () => CollateralsService, getLoanTransactionsService: () => LoanTransactionsService, getQuickbooksService: () => QuickbooksService, getLockService: () => LockService, userLogsService: UserLogsService, borrowersDB: BorrowersDB, usersService: UsersService);
|
|
77
79
|
createUploadFile(file: IMulterFile, borrowerId: string, userId: string, uploadType: EUploadTypes): Promise<mongoose.Document<unknown, {}, IUploadedFileDoc> & IUploadedFileDoc & {
|
|
78
80
|
_id: mongoose.Types.ObjectId;
|
|
79
81
|
}>;
|
|
@@ -48,7 +48,6 @@ const InventoryManualEntry_model_1 = require("../models/InventoryManualEntry.mod
|
|
|
48
48
|
const UserLog_model_1 = require("../models/UserLog.model");
|
|
49
49
|
const microservice_tasks_db_1 = require("../db/microservice-tasks.db");
|
|
50
50
|
const microservice_task_enum_1 = require("../enums/microservice-task.enum");
|
|
51
|
-
const User_model_1 = require("../models/User.model");
|
|
52
51
|
const UploadedFile_model_1 = __importDefault(require("../models/UploadedFile.model"));
|
|
53
52
|
const UploadedSheet_model_1 = __importDefault(require("../models/UploadedSheet.model"));
|
|
54
53
|
const UploadedData_model_1 = __importDefault(require("../models/UploadedData.model"));
|
|
@@ -101,7 +100,8 @@ class UploadsService {
|
|
|
101
100
|
getLockService;
|
|
102
101
|
userLogsService;
|
|
103
102
|
borrowersDB;
|
|
104
|
-
|
|
103
|
+
usersService;
|
|
104
|
+
constructor(rootDir, bankUploadedTransactionsService, getCollateralsService, getLoanTransactionsService, getQuickbooksService, getLockService, userLogsService, borrowersDB, usersService) {
|
|
105
105
|
this.rootDir = rootDir;
|
|
106
106
|
this.bankUploadedTransactionsService = bankUploadedTransactionsService;
|
|
107
107
|
this.getCollateralsService = getCollateralsService;
|
|
@@ -110,6 +110,7 @@ class UploadsService {
|
|
|
110
110
|
this.getLockService = getLockService;
|
|
111
111
|
this.userLogsService = userLogsService;
|
|
112
112
|
this.borrowersDB = borrowersDB;
|
|
113
|
+
this.usersService = usersService;
|
|
113
114
|
}
|
|
114
115
|
async createUploadFile(file, borrowerId, userId, uploadType) {
|
|
115
116
|
const borrowerIdToWrite = new mongoose_1.default.Types.ObjectId(borrowerId);
|
|
@@ -402,7 +403,7 @@ class UploadsService {
|
|
|
402
403
|
default: {
|
|
403
404
|
const collateralsService = this.getCollateralsService();
|
|
404
405
|
const bbcDateId = await collateralsService.saveCollateralItems(newCollateralData, collaterals_enum_1.ECollaterals[mapData.sheetType]);
|
|
405
|
-
const user = await
|
|
406
|
+
const user = await this.usersService.getUserById(userId);
|
|
406
407
|
if (user) {
|
|
407
408
|
const params = {
|
|
408
409
|
borrowerId: new mongoose_1.default.Types.ObjectId(borrowerId),
|
|
@@ -27,7 +27,6 @@ import { InventoryManualEntryModel } from '../models/InventoryManualEntry.model'
|
|
|
27
27
|
import { ELogActionType, ELogType } from '../models/UserLog.model';
|
|
28
28
|
import { createMicroserviceTasks } from '../db/microservice-tasks.db';
|
|
29
29
|
import { EMicroserviceTask } from '../enums/microservice-task.enum';
|
|
30
|
-
import { UserModel } from '../models/User.model';
|
|
31
30
|
|
|
32
31
|
import UploadedFile, { IUploadedFile, IUploadedFileDoc } from '../models/UploadedFile.model';
|
|
33
32
|
import UploadedSheet, {
|
|
@@ -53,6 +52,7 @@ import { QuickbooksService } from './quickbooks.service';
|
|
|
53
52
|
import { UserLogsService } from './user-logs.service';
|
|
54
53
|
import { LockService } from './lock.service';
|
|
55
54
|
import { BorrowersDB } from './borrowers.db';
|
|
55
|
+
import { UsersService } from './users.service';
|
|
56
56
|
|
|
57
57
|
interface IMappedColumns {
|
|
58
58
|
[columnName: string]: number;
|
|
@@ -129,6 +129,7 @@ export class UploadsService {
|
|
|
129
129
|
private readonly getLockService: () => LockService,
|
|
130
130
|
private readonly userLogsService: UserLogsService,
|
|
131
131
|
private readonly borrowersDB: BorrowersDB,
|
|
132
|
+
private readonly usersService: UsersService,
|
|
132
133
|
) {
|
|
133
134
|
}
|
|
134
135
|
|
|
@@ -454,7 +455,7 @@ export class UploadsService {
|
|
|
454
455
|
default: {
|
|
455
456
|
const collateralsService = this.getCollateralsService();
|
|
456
457
|
const bbcDateId = await collateralsService.saveCollateralItems(newCollateralData, ECollaterals[mapData.sheetType]);
|
|
457
|
-
const user = await
|
|
458
|
+
const user = await this.usersService.getUserById(userId);
|
|
458
459
|
if (user) {
|
|
459
460
|
const params = {
|
|
460
461
|
borrowerId: new mongoose.Types.ObjectId(borrowerId),
|
|
@@ -24,159 +24,37 @@
|
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import express from 'express';
|
|
26
26
|
import mongoose from 'mongoose';
|
|
27
|
-
import {
|
|
28
|
-
import { IUser, IUserDocument } from '../models/User.model';
|
|
29
|
-
import { IGroupedKeycloakRoles, IKeycloakRole } from '../interfaces/keycloak-role.interface';
|
|
27
|
+
import { IUser } from '../interfaces/auth-user.interface';
|
|
30
28
|
interface IKeycloakConfig {
|
|
31
29
|
keycloakHost: string;
|
|
32
30
|
realm: string;
|
|
33
31
|
adminUser: string;
|
|
34
32
|
adminPass: string;
|
|
33
|
+
baseUrl: string;
|
|
35
34
|
}
|
|
36
35
|
export declare class UsersService {
|
|
37
36
|
private readonly config;
|
|
38
37
|
constructor(config: IKeycloakConfig);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
getUsersWithRoles(authorization: string): Promise<{
|
|
47
|
-
keycloakUserId: string;
|
|
48
|
-
_id: any;
|
|
49
|
-
allBorrowers: boolean;
|
|
50
|
-
borrowersAccess: mongoose.FlattenMaps<{
|
|
51
|
-
borrower: string;
|
|
52
|
-
}>[];
|
|
53
|
-
lastLogin: Date;
|
|
54
|
-
mobileAccess: {
|
|
55
|
-
hasAccess: boolean;
|
|
56
|
-
canSignDocument: boolean;
|
|
57
|
-
};
|
|
58
|
-
email: string;
|
|
59
|
-
firstName: string;
|
|
60
|
-
lastName: string;
|
|
61
|
-
enabled: boolean;
|
|
62
|
-
username: string;
|
|
63
|
-
roles?: IGroupedKeycloakRoles;
|
|
64
|
-
emailVerified: boolean;
|
|
65
|
-
access: {
|
|
66
|
-
manageGroupMembership: boolean;
|
|
67
|
-
view: boolean;
|
|
68
|
-
mapRoles: boolean;
|
|
69
|
-
impersonate: boolean;
|
|
70
|
-
manage: boolean;
|
|
71
|
-
};
|
|
72
|
-
impersonate: boolean;
|
|
73
|
-
manage: boolean;
|
|
74
|
-
manageGroupMembership: boolean;
|
|
75
|
-
mapRoles: boolean;
|
|
76
|
-
view: boolean;
|
|
77
|
-
createdTimestamp: number;
|
|
78
|
-
disableableCredentialTypes: any[];
|
|
79
|
-
notBefore: number;
|
|
80
|
-
requiredActions: any[];
|
|
81
|
-
totp: boolean;
|
|
82
|
-
attributes?: {
|
|
83
|
-
[key: string]: string[];
|
|
84
|
-
};
|
|
85
|
-
}[]>;
|
|
86
|
-
getUserRoles(authorization: string, userId: string): Promise<{
|
|
87
|
-
realmMappings: IKeycloakRole[];
|
|
88
|
-
}>;
|
|
89
|
-
createUser(authorization: string, user: any): Promise<any>;
|
|
90
|
-
updateUser(authorization: string, userId: string, keyValue: any): Promise<any>;
|
|
38
|
+
getUserAccessByRequest(req: express.Request): Promise<IUser | null>;
|
|
39
|
+
getUserById(userId: string): Promise<IUser | null>;
|
|
40
|
+
getUserByUsername(username: string): Promise<IUser | null>;
|
|
41
|
+
getUserByToken(req: express.Request): Promise<IUser | null>;
|
|
42
|
+
getUserIdByToken(req: express.Request): Promise<string | null>;
|
|
43
|
+
getUserList(): Promise<IUser[]>;
|
|
44
|
+
getUserRoles(userId: string): Promise<Record<string, string[]>>;
|
|
91
45
|
updateMobileUser(userId: string, keyValue: {
|
|
92
46
|
[key: string]: string | number | boolean;
|
|
93
47
|
}): Promise<void>;
|
|
94
|
-
|
|
95
|
-
removeUserRoles(authorization: string, userId: string, roles: IKeycloakRole[]): Promise<any>;
|
|
96
|
-
addUserRoles(authorization: string, userId: string, roles: IKeycloakRole[]): Promise<any>;
|
|
97
|
-
resetPassword(authorization: string, userId: string, temporaryPassword: string): Promise<any>;
|
|
98
|
-
createNewPasswordWithEmail(authorization: string, userId: string, newPassword: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
99
|
-
deleteUser(authorization: string, userId: string): Promise<void>;
|
|
100
|
-
getRoleList(authorization: string): Promise<IKeycloakRole[]>;
|
|
101
|
-
groupRoles(roles: IKeycloakRole[]): IGroupedKeycloakRoles;
|
|
102
|
-
mapRolesToUsers(authorization: string, users: IKeycloakUser[]): Promise<{
|
|
103
|
-
roles: IGroupedKeycloakRoles;
|
|
104
|
-
id: string;
|
|
105
|
-
username: string;
|
|
106
|
-
firstName: string;
|
|
107
|
-
lastName: string;
|
|
108
|
-
enabled: boolean;
|
|
109
|
-
email: string;
|
|
110
|
-
emailVerified: boolean;
|
|
111
|
-
access: {
|
|
112
|
-
manageGroupMembership: boolean;
|
|
113
|
-
view: boolean;
|
|
114
|
-
mapRoles: boolean;
|
|
115
|
-
impersonate: boolean;
|
|
116
|
-
manage: boolean;
|
|
117
|
-
};
|
|
118
|
-
impersonate: boolean;
|
|
119
|
-
manage: boolean;
|
|
120
|
-
manageGroupMembership: boolean;
|
|
121
|
-
mapRoles: boolean;
|
|
122
|
-
view: boolean;
|
|
123
|
-
createdTimestamp: number;
|
|
124
|
-
disableableCredentialTypes: any[];
|
|
125
|
-
notBefore: number;
|
|
126
|
-
requiredActions: any[];
|
|
127
|
-
totp: boolean;
|
|
128
|
-
attributes?: {
|
|
129
|
-
[key: string]: string[];
|
|
130
|
-
};
|
|
131
|
-
}[]>;
|
|
132
|
-
addUserAccess(users: IKeycloakUser[]): Promise<{
|
|
133
|
-
keycloakUserId: string;
|
|
134
|
-
_id: any;
|
|
48
|
+
getUserAccess(userId: string): Promise<{
|
|
135
49
|
allBorrowers: boolean;
|
|
136
|
-
borrowersAccess:
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
hasAccess: boolean;
|
|
142
|
-
canSignDocument: boolean;
|
|
143
|
-
};
|
|
144
|
-
email: string;
|
|
145
|
-
firstName: string;
|
|
146
|
-
lastName: string;
|
|
147
|
-
enabled: boolean;
|
|
148
|
-
username: string;
|
|
149
|
-
roles?: IGroupedKeycloakRoles;
|
|
150
|
-
emailVerified: boolean;
|
|
151
|
-
access: {
|
|
152
|
-
manageGroupMembership: boolean;
|
|
153
|
-
view: boolean;
|
|
154
|
-
mapRoles: boolean;
|
|
155
|
-
impersonate: boolean;
|
|
156
|
-
manage: boolean;
|
|
157
|
-
};
|
|
158
|
-
impersonate: boolean;
|
|
159
|
-
manage: boolean;
|
|
160
|
-
manageGroupMembership: boolean;
|
|
161
|
-
mapRoles: boolean;
|
|
162
|
-
view: boolean;
|
|
163
|
-
createdTimestamp: number;
|
|
164
|
-
disableableCredentialTypes: any[];
|
|
165
|
-
notBefore: number;
|
|
166
|
-
requiredActions: any[];
|
|
167
|
-
totp: boolean;
|
|
168
|
-
attributes?: {
|
|
169
|
-
[key: string]: string[];
|
|
170
|
-
};
|
|
171
|
-
}[]>;
|
|
172
|
-
getUserAccess(keycloakUserId: string): Promise<IUser>;
|
|
173
|
-
getUserAccessByRequest(req: any): Promise<IUser>;
|
|
174
|
-
updateUserLastLogin(authorization: string): Promise<void>;
|
|
50
|
+
borrowersAccess: string[];
|
|
51
|
+
complianceBorrowersAccess: {
|
|
52
|
+
borrower: any;
|
|
53
|
+
}[];
|
|
54
|
+
}>;
|
|
175
55
|
createUserLoginLog(): Promise<void>;
|
|
176
56
|
getUserLogByDate(userId: string, date: Date): Promise<mongoose.FlattenMaps<import("../models/UserLog.model").IUserLog> & Required<{
|
|
177
57
|
_id: mongoose.Types.ObjectId;
|
|
178
58
|
}>>;
|
|
179
|
-
getUserSecrets(keycloakUserId: string, adminAccessToken: string): Promise<void>;
|
|
180
|
-
updateUserNames(): Promise<void>;
|
|
181
59
|
}
|
|
182
60
|
export {};
|