gemcap-be-common 1.4.1 → 1.4.3
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 +7 -0
- package/interfaces/auth-user.interface.ts +8 -0
- package/models/AvailabilitySigns.model.d.ts +11 -11
- package/models/AvailabilitySigns.model.js +2 -4
- package/models/AvailabilitySigns.model.ts +7 -9
- package/models/ReceivableAvailability.model.d.ts +8 -8
- package/models/ReceivableAvailability.model.ts +2 -2
- package/models/_index.d.ts +6 -6
- package/package.json +1 -1
- package/services/availability.service.d.ts +5 -5
- package/services/availability.service.js +1 -1
- package/services/availability.service.ts +6 -7
- package/services/compliance-borrowers.service.d.ts +3 -3
- package/services/compliance-borrowers.service.js +1 -1
- package/services/compliance-borrowers.service.ts +3 -4
- package/services/signs.service.d.ts +2 -3
- package/services/signs.service.js +8 -9
- package/services/signs.service.ts +11 -13
- package/services/users.service.d.ts +3 -2
- package/services/users.service.js +9 -1
- package/services/users.service.ts +13 -4
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import express from 'express';
|
|
26
26
|
import mongoose from 'mongoose';
|
|
27
|
-
import { IUser } from '../interfaces/auth-user.interface';
|
|
27
|
+
import { IRole, IUser } from '../interfaces/auth-user.interface';
|
|
28
28
|
interface IKeycloakConfig {
|
|
29
29
|
keycloakHost: string;
|
|
30
30
|
realm: string;
|
|
@@ -41,7 +41,8 @@ export declare class UsersService {
|
|
|
41
41
|
getUserByToken(req: express.Request): Promise<IUser | null>;
|
|
42
42
|
getUserIdByToken(req: express.Request): Promise<string | null>;
|
|
43
43
|
getUserList(): Promise<IUser[]>;
|
|
44
|
-
|
|
44
|
+
getAllRoles(): Promise<IRole[]>;
|
|
45
|
+
getUserRoles(userId: string): Promise<string[]>;
|
|
45
46
|
updateMobileUser(userId: string, keyValue: {
|
|
46
47
|
[key: string]: string | number | boolean;
|
|
47
48
|
}): Promise<void>;
|
|
@@ -54,9 +54,17 @@ class UsersService {
|
|
|
54
54
|
const { data } = await axios_1.default.get(`${this.config.baseUrl}/users/users`);
|
|
55
55
|
return data ?? null;
|
|
56
56
|
}
|
|
57
|
+
async getAllRoles() {
|
|
58
|
+
const { data } = await axios_1.default.get(`${this.config.baseUrl}/users/roles`);
|
|
59
|
+
return data ?? null;
|
|
60
|
+
}
|
|
57
61
|
async getUserRoles(userId) {
|
|
58
62
|
const user = await this.getUserById(userId);
|
|
59
|
-
|
|
63
|
+
const roles = await this.getAllRoles();
|
|
64
|
+
const userRoleIds = Object.values(user.roles).reduce((acc, roleIds) => [...acc, ...roleIds], []);
|
|
65
|
+
return roles
|
|
66
|
+
.filter((role) => userRoleIds.includes(role.id))
|
|
67
|
+
.map((role) => role.name);
|
|
60
68
|
}
|
|
61
69
|
async updateMobileUser(userId, keyValue) {
|
|
62
70
|
await UserMobileAccess_model_1.UserMobileAccess.findOneAndUpdate({ keycloakUserId: userId }, keyValue, { upsert: true });
|
|
@@ -6,7 +6,7 @@ import mongoose from 'mongoose';
|
|
|
6
6
|
import { BorrowerCompliance } from '../models/BorrowerCompliance.model';
|
|
7
7
|
import { UserMobileAccess } from '../models/UserMobileAccess.model';
|
|
8
8
|
import { UserLog } from '../models/UserLog.model';
|
|
9
|
-
import { IUser } from '../interfaces/auth-user.interface';
|
|
9
|
+
import { IRole, IUser } from '../interfaces/auth-user.interface';
|
|
10
10
|
|
|
11
11
|
interface IKeycloakConfig {
|
|
12
12
|
keycloakHost: string;
|
|
@@ -63,14 +63,23 @@ export class UsersService {
|
|
|
63
63
|
return null;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
async getUserList()
|
|
67
|
-
const { data } = await axios.get(`${this.config.baseUrl}/users/users`);
|
|
66
|
+
async getUserList() {
|
|
67
|
+
const { data } = await axios.get<IUser[]>(`${this.config.baseUrl}/users/users`);
|
|
68
|
+
return data ?? null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async getAllRoles() {
|
|
72
|
+
const { data } = await axios.get<IRole[]>(`${this.config.baseUrl}/users/roles`);
|
|
68
73
|
return data ?? null;
|
|
69
74
|
}
|
|
70
75
|
|
|
71
76
|
async getUserRoles(userId: string) {
|
|
72
77
|
const user = await this.getUserById(userId);
|
|
73
|
-
|
|
78
|
+
const roles = await this.getAllRoles();
|
|
79
|
+
const userRoleIds = Object.values(user.roles).reduce((acc, roleIds) => [...acc, ...roleIds], []);
|
|
80
|
+
return roles
|
|
81
|
+
.filter((role) => userRoleIds.includes(role.id))
|
|
82
|
+
.map((role) => role.name);
|
|
74
83
|
}
|
|
75
84
|
|
|
76
85
|
async updateMobileUser(userId: string, keyValue: { [key: string]: string | number | boolean }) {
|