gemcap-be-common 1.4.11 → 1.4.13

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.
@@ -12,6 +12,9 @@ const createLog = async (params) => {
12
12
  if (!createLogs) {
13
13
  return;
14
14
  }
15
+ if (!params.userId) {
16
+ return;
17
+ }
15
18
  const newUserLog = new UserLog_model_1.UserLog({
16
19
  timestamp: params.timestamp ? params.timestamp : new Date(),
17
20
  logType: params.logType,
@@ -21,6 +21,9 @@ export const createLog = async (params: ICreateLogParams) => {
21
21
  if (!createLogs) {
22
22
  return;
23
23
  }
24
+ if (!params.userId) {
25
+ return;
26
+ }
24
27
  const newUserLog = new UserLog({
25
28
  timestamp: params.timestamp ? params.timestamp : new Date(),
26
29
  logType: params.logType,
@@ -27,7 +27,7 @@ export interface IUserLegacy {
27
27
  isDeleted?: boolean;
28
28
  firstName?: string;
29
29
  lastName?: string;
30
- keycloakUserId?: string;
30
+ userId?: string;
31
31
  allBorrowers: boolean;
32
32
  lastLogin?: Date;
33
33
  borrowersAccess: {
@@ -42,8 +42,8 @@ export declare const UserSchema: mongoose.Schema<any, mongoose.Model<any, any, a
42
42
  createdAt: NativeDate;
43
43
  updatedAt: NativeDate;
44
44
  } & {
45
+ userId: string;
45
46
  isDeleted: boolean;
46
- keycloakUserId: string;
47
47
  borrowersAccess: mongoose.Types.DocumentArray<{
48
48
  borrower: string;
49
49
  }>;
@@ -56,8 +56,8 @@ export declare const UserSchema: mongoose.Schema<any, mongoose.Model<any, any, a
56
56
  createdAt: NativeDate;
57
57
  updatedAt: NativeDate;
58
58
  } & {
59
+ userId: string;
59
60
  isDeleted: boolean;
60
- keycloakUserId: string;
61
61
  borrowersAccess: mongoose.Types.DocumentArray<{
62
62
  borrower: string;
63
63
  }>;
@@ -70,8 +70,8 @@ export declare const UserSchema: mongoose.Schema<any, mongoose.Model<any, any, a
70
70
  createdAt: NativeDate;
71
71
  updatedAt: NativeDate;
72
72
  } & {
73
+ userId: string;
73
74
  isDeleted: boolean;
74
- keycloakUserId: string;
75
75
  borrowersAccess: mongoose.Types.DocumentArray<{
76
76
  borrower: string;
77
77
  }>;
@@ -12,7 +12,7 @@ exports.UserSchema = new mongoose_1.default.Schema({
12
12
  type: Boolean,
13
13
  default: false,
14
14
  },
15
- keycloakUserId: {
15
+ userId: {
16
16
  type: String,
17
17
  trim: true,
18
18
  required: true,
@@ -8,7 +8,7 @@ export interface IUserLegacy {
8
8
  isDeleted?: boolean;
9
9
  firstName?: string;
10
10
  lastName?: string;
11
- keycloakUserId?: string;
11
+ userId?: string;
12
12
  allBorrowers: boolean;
13
13
  lastLogin?: Date;
14
14
  borrowersAccess: {
@@ -25,7 +25,7 @@ export const UserSchema = new mongoose.Schema(
25
25
  type: Boolean,
26
26
  default: false,
27
27
  },
28
- keycloakUserId: {
28
+ userId: {
29
29
  type: String,
30
30
  trim: true,
31
31
  required: true,
@@ -25,7 +25,7 @@
25
25
  import mongoose, { Model } from 'mongoose';
26
26
  export interface IUserMobileAccess {
27
27
  _id?: mongoose.Types.ObjectId;
28
- keycloakUserId?: string;
28
+ userId?: string;
29
29
  hasAccess: boolean;
30
30
  canSignDocument: boolean;
31
31
  }
@@ -7,7 +7,7 @@ exports.UserMobileAccess = exports.UserMobileAccessSchema = void 0;
7
7
  const mongoose_1 = __importDefault(require("mongoose"));
8
8
  const _models_1 = require("./_models");
9
9
  exports.UserMobileAccessSchema = new mongoose_1.default.Schema({
10
- keycloakUserId: {
10
+ userId: {
11
11
  type: String,
12
12
  trim: true,
13
13
  required: true,
@@ -4,7 +4,7 @@ import { MODEL_NAMES } from './_models';
4
4
 
5
5
  export interface IUserMobileAccess {
6
6
  _id?: mongoose.Types.ObjectId;
7
- keycloakUserId?: string;
7
+ userId?: string;
8
8
  hasAccess: boolean;
9
9
  canSignDocument: boolean;
10
10
  }
@@ -13,7 +13,7 @@ type UserMobileAccessModel = Model<IUserMobileAccess, {}, {}>;
13
13
 
14
14
  export const UserMobileAccessSchema = new mongoose.Schema<IUserMobileAccess, UserMobileAccessModel>(
15
15
  {
16
- keycloakUserId: {
16
+ userId: {
17
17
  type: String,
18
18
  trim: true,
19
19
  required: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemcap-be-common",
3
- "version": "1.4.11",
3
+ "version": "1.4.13",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -39,8 +39,8 @@ class UsersService {
39
39
  if (!authorization) {
40
40
  return null;
41
41
  }
42
- const { sub: keycloakUserId } = (0, jwt_decode_1.jwtDecode)(authorization);
43
- return this.getUserById(keycloakUserId);
42
+ const { sub } = (0, jwt_decode_1.jwtDecode)(authorization);
43
+ return this.getUserById(sub);
44
44
  }
45
45
  async getUserIdByToken(req) {
46
46
  const user = await this.getUserByToken(req);
@@ -66,7 +66,7 @@ class UsersService {
66
66
  .map((role) => role.name);
67
67
  }
68
68
  async updateMobileUser(userId, keyValue) {
69
- await UserMobileAccess_model_1.UserMobileAccess.findOneAndUpdate({ keycloakUserId: userId }, keyValue, { upsert: true });
69
+ await UserMobileAccess_model_1.UserMobileAccess.findOneAndUpdate({ userId }, keyValue, { upsert: true });
70
70
  }
71
71
  async getUserAccess(userId) {
72
72
  const foundUser = await this.getUserById(userId);
@@ -105,7 +105,7 @@ class UsersService {
105
105
  // userDates[userId].add(formattedDate);
106
106
  // });
107
107
  // await Promise.all(Object.entries(userDates).map(async ([userId, dateSet]) => {
108
- // const user = await UserModel.findOne({ keycloakUserId: userId });
108
+ // const user = await UserModel.findOne({ userId });
109
109
  // if (!user) {
110
110
  // return;
111
111
  // }
@@ -46,8 +46,8 @@ export class UsersService {
46
46
  if (!authorization) {
47
47
  return null;
48
48
  }
49
- const { sub: keycloakUserId }: { sub: string } = jwtDecode(authorization);
50
- return this.getUserById(keycloakUserId);
49
+ const { sub }: { sub: string } = jwtDecode(authorization);
50
+ return this.getUserById(sub);
51
51
  }
52
52
 
53
53
  async getUserIdByToken(req: express.Request) {
@@ -78,7 +78,7 @@ export class UsersService {
78
78
  }
79
79
 
80
80
  async updateMobileUser(userId: string, keyValue: { [key: string]: string | number | boolean }) {
81
- await UserMobileAccess.findOneAndUpdate({ keycloakUserId: userId }, keyValue, { upsert: true });
81
+ await UserMobileAccess.findOneAndUpdate({ userId }, keyValue, { upsert: true });
82
82
  }
83
83
 
84
84
  async getUserAccess(userId: string): Promise<IUserAccess> {
@@ -120,7 +120,7 @@ export class UsersService {
120
120
  // userDates[userId].add(formattedDate);
121
121
  // });
122
122
  // await Promise.all(Object.entries(userDates).map(async ([userId, dateSet]) => {
123
- // const user = await UserModel.findOne({ keycloakUserId: userId });
123
+ // const user = await UserModel.findOne({ userId });
124
124
  // if (!user) {
125
125
  // return;
126
126
  // }