ecrs-auth-core 1.0.73 → 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
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ecrs-auth-core",
3
- "version": "1.0.73",
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",