ecrs-auth-core 1.0.72 → 1.0.74

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.
@@ -26,6 +26,8 @@ export declare class AuthController {
26
26
  dispatchCenterId: any;
27
27
  departmentId: any;
28
28
  designationId: any;
29
+ lastLoginTime: any;
30
+ is_otp_verified: number | boolean;
29
31
  profile_photo_url: string;
30
32
  };
31
33
  };
@@ -124,6 +124,11 @@ let AuthController = class AuthController {
124
124
  getClientIp(request) {
125
125
  // Check X-Forwarded-For header (most common with proxies)
126
126
  const xForwardedFor = request.headers['x-forwarded-for'];
127
+ console.log('X-Forwarded-For header:', xForwardedFor);
128
+ console.log('Request IP:', request.ip);
129
+ console.log('Socket Remote Address:', request.socket.remoteAddress);
130
+ console.log('X-Real-IP header:', request.headers['x-real-ip']);
131
+ console.log('CF-Connecting-IP header:', request.headers['cf-connecting-ip']);
127
132
  if (xForwardedFor) {
128
133
  const ips = Array.isArray(xForwardedFor)
129
134
  ? xForwardedFor
@@ -81,6 +81,8 @@ export declare class AuthService {
81
81
  dispatchCenterId: any;
82
82
  departmentId: any;
83
83
  designationId: any;
84
+ lastLoginTime: any;
85
+ is_otp_verified: number | boolean;
84
86
  profile_photo_url: string;
85
87
  };
86
88
  };
@@ -213,7 +213,7 @@ let AuthService = class AuthService {
213
213
  let dispatchCenterId = null;
214
214
  let departmentId = null;
215
215
  let designationId = null;
216
- if (this.employeeWorkProfileRepo) {
216
+ if (this.employeeWorkProfileRepo && user.referenceId != null) {
217
217
  try {
218
218
  const workProfile = await this.employeeWorkProfileRepo.findOne({
219
219
  where: { employee_id: user.referenceId },
@@ -230,6 +230,25 @@ let AuthService = class AuthService {
230
230
  // Continue with null values if fetch fails
231
231
  }
232
232
  }
233
+ // Fetch last login details
234
+ let lastLoginTime = null;
235
+ let lastLoginStatus = null;
236
+ let lastLoginIpAddress = null;
237
+ if (this.userLastLoginRepo) {
238
+ try {
239
+ const lastLogin = await this.userLastLoginRepo.findOne({
240
+ where: { user_id: user.id },
241
+ order: { login_time: 'DESC' },
242
+ });
243
+ if (lastLogin) {
244
+ lastLoginTime = lastLogin?.login_time || null;
245
+ }
246
+ }
247
+ catch (error) {
248
+ console.error('Error fetching last login details:', error);
249
+ // Continue with null values if fetch fails
250
+ }
251
+ }
233
252
  const payload = {
234
253
  id: user.id,
235
254
  email: user.email,
@@ -249,6 +268,8 @@ let AuthService = class AuthService {
249
268
  dispatchCenterId,
250
269
  departmentId,
251
270
  designationId,
271
+ lastLoginTime: lastLoginTime,
272
+ is_otp_verified: user.isOtpVerified || false,
252
273
  };
253
274
  return {
254
275
  status: true,
@@ -272,6 +293,8 @@ let AuthService = class AuthService {
272
293
  dispatchCenterId,
273
294
  departmentId,
274
295
  designationId,
296
+ lastLoginTime: lastLoginTime,
297
+ is_otp_verified: user.isOtpVerified || false,
275
298
  profile_photo_url: `${this.uploadPhotoDir}`,
276
299
  },
277
300
  },
@@ -47,19 +47,19 @@ __decorate([
47
47
  __metadata("design:type", Number)
48
48
  ], EmployeeWorkProfileEntity.prototype, "id", void 0);
49
49
  __decorate([
50
- (0, typeorm_1.Column)({ name: 'employee_id', type: 'int' }),
50
+ (0, typeorm_1.Column)({ name: 'employee_id', type: 'int', nullable: true }),
51
51
  __metadata("design:type", Number)
52
52
  ], EmployeeWorkProfileEntity.prototype, "employee_id", void 0);
53
53
  __decorate([
54
- (0, typeorm_1.Column)({ name: 'department_id', type: 'int' }),
54
+ (0, typeorm_1.Column)({ name: 'department_id', type: 'int', nullable: true }),
55
55
  __metadata("design:type", Number)
56
56
  ], EmployeeWorkProfileEntity.prototype, "department_id", void 0);
57
57
  __decorate([
58
- (0, typeorm_1.Column)({ name: 'designation_id', type: 'int' }),
58
+ (0, typeorm_1.Column)({ name: 'designation_id', type: 'int', nullable: true }),
59
59
  __metadata("design:type", Number)
60
60
  ], EmployeeWorkProfileEntity.prototype, "designation_id", void 0);
61
61
  __decorate([
62
- (0, typeorm_1.Column)({ type: 'enum', enum: EmployeeType, nullable: false }),
62
+ (0, typeorm_1.Column)({ type: 'enum', enum: EmployeeType, nullable: true }),
63
63
  __metadata("design:type", String)
64
64
  ], EmployeeWorkProfileEntity.prototype, "employee_type", void 0);
65
65
  __decorate([
@@ -76,7 +76,7 @@ __decorate([
76
76
  __metadata("design:type", Number)
77
77
  ], EmployeeWorkProfileEntity.prototype, "shift_id", void 0);
78
78
  __decorate([
79
- (0, typeorm_1.Column)({ name: 'role_id', type: 'int' }),
79
+ (0, typeorm_1.Column)({ name: 'role_id', type: 'int', nullable: true }),
80
80
  __metadata("design:type", Number)
81
81
  ], EmployeeWorkProfileEntity.prototype, "role_id", void 0);
82
82
  __decorate([
@@ -92,7 +92,7 @@ __decorate([
92
92
  __metadata("design:type", Object)
93
93
  ], EmployeeWorkProfileEntity.prototype, "l2_manager_id", void 0);
94
94
  __decorate([
95
- (0, typeorm_1.Column)({ type: 'date', nullable: false }),
95
+ (0, typeorm_1.Column)({ type: 'date', nullable: true }),
96
96
  __metadata("design:type", Date)
97
97
  ], EmployeeWorkProfileEntity.prototype, "joining_date", void 0);
98
98
  __decorate([
@@ -108,14 +108,14 @@ __decorate([
108
108
  __metadata("design:type", Number)
109
109
  ], EmployeeWorkProfileEntity.prototype, "dispatch_center_id", void 0);
110
110
  __decorate([
111
- (0, typeorm_1.Column)({ name: 'cost_center_id', type: 'int' }),
111
+ (0, typeorm_1.Column)({ name: 'cost_center_id', type: 'int', nullable: true }),
112
112
  __metadata("design:type", Number)
113
113
  ], EmployeeWorkProfileEntity.prototype, "cost_center_id", void 0);
114
114
  __decorate([
115
115
  (0, typeorm_1.Column)({
116
116
  type: 'enum',
117
117
  enum: WeekOffType,
118
- nullable: false,
118
+ nullable: true,
119
119
  }),
120
120
  __metadata("design:type", String)
121
121
  ], EmployeeWorkProfileEntity.prototype, "week_off_type", void 0);
@@ -123,7 +123,7 @@ __decorate([
123
123
  (0, typeorm_1.Column)({
124
124
  type: 'enum',
125
125
  enum: WeekOffBasedOn,
126
- nullable: false,
126
+ nullable: true,
127
127
  }),
128
128
  __metadata("design:type", String)
129
129
  ], EmployeeWorkProfileEntity.prototype, "week_off_based_on", void 0);
@@ -136,7 +136,7 @@ __decorate([
136
136
  __metadata("design:type", String)
137
137
  ], EmployeeWorkProfileEntity.prototype, "linkedInProfile", void 0);
138
138
  __decorate([
139
- (0, typeorm_1.CreateDateColumn)({ type: 'timestamp' }),
139
+ (0, typeorm_1.CreateDateColumn)({ type: 'timestamp', nullable: true }),
140
140
  __metadata("design:type", Date)
141
141
  ], EmployeeWorkProfileEntity.prototype, "created_at", void 0);
142
142
  __decorate([
@@ -144,7 +144,7 @@ __decorate([
144
144
  __metadata("design:type", Number)
145
145
  ], EmployeeWorkProfileEntity.prototype, "created_by", void 0);
146
146
  __decorate([
147
- (0, typeorm_1.UpdateDateColumn)({ type: 'timestamp' }),
147
+ (0, typeorm_1.UpdateDateColumn)({ type: 'timestamp', nullable: true }),
148
148
  __metadata("design:type", Date)
149
149
  ], EmployeeWorkProfileEntity.prototype, "updated_at", void 0);
150
150
  __decorate([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ecrs-auth-core",
3
- "version": "1.0.72",
3
+ "version": "1.0.74",
4
4
  "description": "Centralized authentication and authorization module for ECRS apps",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",