ecrs-auth-core 1.0.104 → 1.0.106
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/dist/auth-customer.controller.d.ts +48 -0
- package/dist/auth-customer.controller.js +249 -0
- package/dist/auth-customer.module.d.ts +8 -0
- package/dist/auth-customer.module.js +62 -0
- package/dist/auth-customer.service.d.ts +67 -0
- package/dist/auth-customer.service.js +339 -0
- package/dist/constants/constants.d.ts +1 -0
- package/dist/constants/constants.js +2 -1
- package/dist/dtos/login-customer.dto.d.ts +4 -0
- package/dist/dtos/login-customer.dto.js +42 -0
- package/dist/entities/login-details-customer.entity.d.ts +19 -0
- package/dist/entities/login-details-customer.entity.js +91 -0
- package/dist/entities/role-customer.entity.d.ts +6 -0
- package/dist/entities/role-customer.entity.js +40 -0
- package/dist/entities/user-customer-last-login.entity.d.ts +27 -0
- package/dist/entities/user-customer-last-login.entity.js +147 -0
- package/dist/entities/user-customer-module-access.entity copy.d.ts +13 -0
- package/dist/entities/user-customer-module-access.entity copy.js +76 -0
- package/dist/entities/user-customer-module-access.entity.d.ts +13 -0
- package/dist/entities/user-customer-module-access.entity.js +76 -0
- package/dist/entities/user-customer.entity.d.ts +29 -0
- package/dist/entities/user-customer.entity.js +128 -0
- package/dist/entities/user-feature-access.entity.js +25 -17
- package/dist/index.d.ts +41 -31
- package/dist/index.js +12 -0
- package/dist/interfaces/auth-customer-options.interface.d.ts +25 -0
- package/dist/interfaces/auth-customer-options.interface.js +2 -0
- package/dist/jwt/jwt-customer.guard.d.ts +4 -0
- package/dist/jwt/jwt-customer.guard.js +17 -0
- package/dist/jwt/jwt-customer.strategy.d.ts +16 -0
- package/dist/jwt/jwt-customer.strategy.js +78 -0
- package/dist/portal-auth.d.ts +3 -0
- package/dist/portal-auth.js +21 -0
- package/package.json +2 -1
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
45
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.AuthCustomerService = void 0;
|
|
49
|
+
const common_1 = require("@nestjs/common");
|
|
50
|
+
const jwt_1 = require("@nestjs/jwt");
|
|
51
|
+
const bcrypt = __importStar(require("bcrypt"));
|
|
52
|
+
const typeorm_1 = require("typeorm");
|
|
53
|
+
const constants_1 = require("./constants/constants");
|
|
54
|
+
let AuthCustomerService = class AuthCustomerService {
|
|
55
|
+
constructor(jwtService, options) {
|
|
56
|
+
this.jwtService = jwtService;
|
|
57
|
+
this.options = options;
|
|
58
|
+
this.uploadPhotoDir = "uploads/organization/photos";
|
|
59
|
+
const { repositories } = options;
|
|
60
|
+
this.userRepo = repositories.userRepo;
|
|
61
|
+
this.roleRepo = repositories.roleRepo;
|
|
62
|
+
this.moduleAccessRepo = repositories.moduleAccessRepo;
|
|
63
|
+
this.userLastLoginRepo = repositories.userLastLoginRepo || null;
|
|
64
|
+
this.loginDetailsRepo = repositories.loginDetailsRepo || null;
|
|
65
|
+
this.employeeWorkProfileRepo = repositories.employeeWorkProfileRepo || null;
|
|
66
|
+
}
|
|
67
|
+
async validateUser(email, password, clientIp) {
|
|
68
|
+
if (!email || !password || password.length > 72 || email.length > 254) {
|
|
69
|
+
throw new common_1.UnauthorizedException("Invalid credentials");
|
|
70
|
+
}
|
|
71
|
+
const normalizedEmail = email.trim().toLowerCase();
|
|
72
|
+
const whereClause = {
|
|
73
|
+
email: (0, typeorm_1.ILike)(normalizedEmail),
|
|
74
|
+
deletedBy: (0, typeorm_1.IsNull)(),
|
|
75
|
+
deletedAt: (0, typeorm_1.IsNull)(),
|
|
76
|
+
status: 1,
|
|
77
|
+
};
|
|
78
|
+
const user = await this.userRepo.findOne({ where: whereClause });
|
|
79
|
+
const isValid = user
|
|
80
|
+
? await bcrypt.compare(password, user.password)
|
|
81
|
+
: false;
|
|
82
|
+
if (!user || !isValid) {
|
|
83
|
+
throw new common_1.UnauthorizedException("Invalid credentials");
|
|
84
|
+
}
|
|
85
|
+
if (clientIp && this.userLastLoginRepo) {
|
|
86
|
+
// IP restriction check can be added here if needed
|
|
87
|
+
}
|
|
88
|
+
return user;
|
|
89
|
+
}
|
|
90
|
+
async hasModuleAccess(userId, moduleId) {
|
|
91
|
+
if (!Number.isFinite(moduleId))
|
|
92
|
+
return false;
|
|
93
|
+
try {
|
|
94
|
+
const result = await this.moduleAccessRepo.query(`SELECT 1
|
|
95
|
+
FROM tbl_c_users_customer_module_access_new
|
|
96
|
+
WHERE customer_user_id = $1
|
|
97
|
+
AND module_id = $2
|
|
98
|
+
AND status = 1
|
|
99
|
+
AND is_deleted = 0
|
|
100
|
+
LIMIT 1`, [userId, moduleId]);
|
|
101
|
+
return result.length > 0;
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async saveLastLogin(user, clientIp, loginStatus = "success", failureReason, additionalData) {
|
|
108
|
+
if (!this.userLastLoginRepo) {
|
|
109
|
+
console.warn("⚠️ userLastLoginRepo not configured for customer auth.");
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
const lastLoginData = {
|
|
114
|
+
customer_user_id: user.id,
|
|
115
|
+
email: user.email,
|
|
116
|
+
first_name: user.firstName,
|
|
117
|
+
last_name: user.lastName,
|
|
118
|
+
ip_address: clientIp,
|
|
119
|
+
login_status: loginStatus,
|
|
120
|
+
failure_reason: failureReason,
|
|
121
|
+
login_time: new Date(),
|
|
122
|
+
browser: additionalData?.browser,
|
|
123
|
+
device_type: additionalData?.deviceType,
|
|
124
|
+
operating_system: additionalData?.operatingSystem,
|
|
125
|
+
user_agent: additionalData?.userAgent,
|
|
126
|
+
location: additionalData?.location,
|
|
127
|
+
module_id: additionalData?.moduleId,
|
|
128
|
+
ip_address_name: additionalData?.ipAddressName,
|
|
129
|
+
metadata: additionalData?.metadata,
|
|
130
|
+
};
|
|
131
|
+
const existingRecord = await this.userLastLoginRepo.findOne({
|
|
132
|
+
where: { customer_user_id: user.id },
|
|
133
|
+
});
|
|
134
|
+
if (existingRecord) {
|
|
135
|
+
await this.userLastLoginRepo.update({ customer_user_id: user.id }, lastLoginData);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
await this.userLastLoginRepo.save(lastLoginData);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
console.error("Error saving customer last login details:", error);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
async saveLoginDetailsJson(user, clientIp, loginStatus = "success", failureReason, additionalData) {
|
|
146
|
+
if (!this.loginDetailsRepo)
|
|
147
|
+
return;
|
|
148
|
+
try {
|
|
149
|
+
const today = new Date();
|
|
150
|
+
today.setHours(0, 0, 0, 0);
|
|
151
|
+
const loginDetailData = {
|
|
152
|
+
login_time: new Date().toISOString(),
|
|
153
|
+
status: loginStatus,
|
|
154
|
+
ip_address: clientIp,
|
|
155
|
+
browser: additionalData?.browser,
|
|
156
|
+
device_type: additionalData?.deviceType,
|
|
157
|
+
operating_system: additionalData?.operatingSystem,
|
|
158
|
+
location: additionalData?.location,
|
|
159
|
+
module_id: additionalData?.moduleId,
|
|
160
|
+
ip_address_name: additionalData?.ipAddressName,
|
|
161
|
+
failure_reason: failureReason,
|
|
162
|
+
user_agent: additionalData?.userAgent,
|
|
163
|
+
metadata: additionalData?.metadata,
|
|
164
|
+
};
|
|
165
|
+
const existingRecord = await this.loginDetailsRepo.findOne({
|
|
166
|
+
where: { customer_user_id: user.id, date: today },
|
|
167
|
+
});
|
|
168
|
+
let loginData = [];
|
|
169
|
+
let successCount = 0;
|
|
170
|
+
let failedCount = 0;
|
|
171
|
+
if (existingRecord) {
|
|
172
|
+
loginData = existingRecord.login_data || [];
|
|
173
|
+
successCount = existingRecord.successful_logins || 0;
|
|
174
|
+
failedCount = existingRecord.failed_logins || 0;
|
|
175
|
+
loginData.push(loginDetailData);
|
|
176
|
+
if (loginStatus === "success")
|
|
177
|
+
successCount++;
|
|
178
|
+
else if (loginStatus === "failed" || loginStatus === "blocked")
|
|
179
|
+
failedCount++;
|
|
180
|
+
await this.loginDetailsRepo.update({ id: existingRecord.id }, {
|
|
181
|
+
login_data: loginData,
|
|
182
|
+
total_logins: loginData.length,
|
|
183
|
+
successful_logins: successCount,
|
|
184
|
+
failed_logins: failedCount,
|
|
185
|
+
updated_at: new Date(),
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
loginData = [loginDetailData];
|
|
190
|
+
successCount = loginStatus === "success" ? 1 : 0;
|
|
191
|
+
failedCount =
|
|
192
|
+
loginStatus === "failed" || loginStatus === "blocked" ? 1 : 0;
|
|
193
|
+
const newLoginDetails = this.loginDetailsRepo.create({
|
|
194
|
+
customer_user_id: user.id,
|
|
195
|
+
date: today,
|
|
196
|
+
email: user.email,
|
|
197
|
+
first_name: user.firstName,
|
|
198
|
+
last_name: user.lastName,
|
|
199
|
+
login_data: loginData,
|
|
200
|
+
total_logins: 1,
|
|
201
|
+
successful_logins: successCount,
|
|
202
|
+
failed_logins: failedCount,
|
|
203
|
+
});
|
|
204
|
+
await this.loginDetailsRepo.save(newLoginDetails);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
console.error("Error saving customer login details JSON:", error);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
async updateLoginLogoutDetailsJson(userId) {
|
|
212
|
+
if (!this.loginDetailsRepo)
|
|
213
|
+
return;
|
|
214
|
+
try {
|
|
215
|
+
const today = new Date();
|
|
216
|
+
today.setHours(0, 0, 0, 0);
|
|
217
|
+
const record = await this.loginDetailsRepo.findOne({
|
|
218
|
+
where: { customer_user_id: userId, date: today },
|
|
219
|
+
});
|
|
220
|
+
if (!record || !record.login_data || record.login_data.length === 0)
|
|
221
|
+
return;
|
|
222
|
+
const loginData = [...record.login_data];
|
|
223
|
+
const lastLogin = loginData[loginData.length - 1];
|
|
224
|
+
const loginTime = new Date(lastLogin.login_time);
|
|
225
|
+
const logoutTime = new Date();
|
|
226
|
+
const sessionDurationMs = logoutTime.getTime() - loginTime.getTime();
|
|
227
|
+
loginData[loginData.length - 1] = {
|
|
228
|
+
...lastLogin,
|
|
229
|
+
logout_time: logoutTime.toISOString(),
|
|
230
|
+
session_duration_ms: sessionDurationMs,
|
|
231
|
+
};
|
|
232
|
+
await this.loginDetailsRepo.update({ id: record.id }, { login_data: loginData, updated_at: new Date() });
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
console.error("Error updating customer logout details:", error);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
async updateLastLoginLogout(userId) {
|
|
239
|
+
if (!this.userLastLoginRepo)
|
|
240
|
+
return;
|
|
241
|
+
try {
|
|
242
|
+
const record = await this.userLastLoginRepo.findOne({
|
|
243
|
+
where: { customer_user_id: userId },
|
|
244
|
+
});
|
|
245
|
+
if (!record || !record.login_time)
|
|
246
|
+
return;
|
|
247
|
+
const logoutTime = new Date();
|
|
248
|
+
const sessionDurationMs = logoutTime.getTime() - new Date(record.login_time).getTime();
|
|
249
|
+
await this.userLastLoginRepo.update({ customer_user_id: userId }, { logout_time: logoutTime, session_duration_ms: sessionDurationMs });
|
|
250
|
+
}
|
|
251
|
+
catch (error) {
|
|
252
|
+
console.error("Error updating customer last login logout time:", error);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
async login(user) {
|
|
256
|
+
const role = await this.roleRepo.findOne({ where: { id: user.roleId } });
|
|
257
|
+
const roleName = role?.roleName || null;
|
|
258
|
+
let lastLoginTime = null;
|
|
259
|
+
if (this.userLastLoginRepo) {
|
|
260
|
+
try {
|
|
261
|
+
const lastLogin = await this.userLastLoginRepo.findOne({
|
|
262
|
+
where: { customer_user_id: user.id },
|
|
263
|
+
order: { login_time: "DESC" },
|
|
264
|
+
});
|
|
265
|
+
if (lastLogin)
|
|
266
|
+
lastLoginTime = lastLogin.login_time || null;
|
|
267
|
+
}
|
|
268
|
+
catch {
|
|
269
|
+
// continue with null
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const is_reset_password = user.isOtpVerified === 0 ? 1 : 0;
|
|
273
|
+
const payload = {
|
|
274
|
+
id: user.id,
|
|
275
|
+
email: user.email,
|
|
276
|
+
roleId: user.roleId,
|
|
277
|
+
roleName,
|
|
278
|
+
tokenVersion: user.token_version || 1,
|
|
279
|
+
name: `${user.firstName} ${user.lastName}`,
|
|
280
|
+
firstName: user.firstName,
|
|
281
|
+
lastName: user.lastName,
|
|
282
|
+
mobileNo: user.mobileNo,
|
|
283
|
+
userImage: user.userImage,
|
|
284
|
+
referenceId: user.referenceId,
|
|
285
|
+
parentId: user.parentId,
|
|
286
|
+
lastLoginTime,
|
|
287
|
+
is_reset_password,
|
|
288
|
+
is_ecrs_employee: user.is_ecrs_employee ?? false, // ✅ ADD THIS
|
|
289
|
+
userId: user.userId, // ✅ ADD THIS
|
|
290
|
+
};
|
|
291
|
+
return {
|
|
292
|
+
status: true,
|
|
293
|
+
message: "Login successful",
|
|
294
|
+
data: {
|
|
295
|
+
user: {
|
|
296
|
+
id: user.id,
|
|
297
|
+
email: user.email,
|
|
298
|
+
roleId: user.roleId,
|
|
299
|
+
roleName,
|
|
300
|
+
tokenVersion: user.token_version || 1,
|
|
301
|
+
name: `${user.firstName} ${user.lastName}`,
|
|
302
|
+
firstName: user.firstName,
|
|
303
|
+
lastName: user.lastName,
|
|
304
|
+
mobileNo: user.mobileNo,
|
|
305
|
+
userImage: user.userImage,
|
|
306
|
+
referenceId: user.referenceId,
|
|
307
|
+
parentId: user.parentId,
|
|
308
|
+
lastLoginTime,
|
|
309
|
+
is_reset_password,
|
|
310
|
+
is_ecrs_employee: user.is_ecrs_employee ?? false,
|
|
311
|
+
userId: user.userId,
|
|
312
|
+
profile_photo_url: `${this.uploadPhotoDir}/${user.userImage}`,
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
access_token: this.jwtService.sign(payload),
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
async findUserById(id) {
|
|
319
|
+
return this.userRepo.findOne({ where: { id } });
|
|
320
|
+
}
|
|
321
|
+
// In auth-customer.service.ts — add this new method
|
|
322
|
+
async findEcrsEmployeeInCustomer(ecrsEmployeeId) {
|
|
323
|
+
return this.userRepo.findOne({
|
|
324
|
+
where: {
|
|
325
|
+
is_ecrs_employee: true,
|
|
326
|
+
referenceId: ecrsEmployeeId, // referenceId holds the ecrs employee id
|
|
327
|
+
status: 1,
|
|
328
|
+
deletedBy: (0, typeorm_1.IsNull)(),
|
|
329
|
+
deletedAt: (0, typeorm_1.IsNull)(),
|
|
330
|
+
},
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
exports.AuthCustomerService = AuthCustomerService;
|
|
335
|
+
exports.AuthCustomerService = AuthCustomerService = __decorate([
|
|
336
|
+
(0, common_1.Injectable)(),
|
|
337
|
+
__param(1, (0, common_1.Inject)(constants_1.AUTH_CUSTOMER_CORE_OPTIONS)),
|
|
338
|
+
__metadata("design:paramtypes", [jwt_1.JwtService, Object])
|
|
339
|
+
], AuthCustomerService);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AUTH_CORE_OPTIONS = void 0;
|
|
3
|
+
exports.AUTH_CUSTOMER_CORE_OPTIONS = exports.AUTH_CORE_OPTIONS = void 0;
|
|
4
4
|
exports.AUTH_CORE_OPTIONS = 'AUTH_CORE_OPTIONS';
|
|
5
|
+
exports.AUTH_CUSTOMER_CORE_OPTIONS = 'AUTH_CUSTOMER_CORE_OPTIONS';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.LoginCustomerDto = void 0;
|
|
13
|
+
// src/dtos/login.dto.ts
|
|
14
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
15
|
+
const class_validator_1 = require("class-validator");
|
|
16
|
+
const class_transformer_1 = require("class-transformer");
|
|
17
|
+
class LoginCustomerDto {
|
|
18
|
+
}
|
|
19
|
+
exports.LoginCustomerDto = LoginCustomerDto;
|
|
20
|
+
__decorate([
|
|
21
|
+
(0, swagger_1.ApiProperty)({
|
|
22
|
+
example: "user@example.com",
|
|
23
|
+
description: "User email address used for login",
|
|
24
|
+
}),
|
|
25
|
+
(0, class_validator_1.IsEmail)(),
|
|
26
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
27
|
+
(0, class_validator_1.MaxLength)(254) // RFC 5321 max; rejects oversized email before DB lookup
|
|
28
|
+
,
|
|
29
|
+
(0, class_transformer_1.Transform)(({ value }) => (typeof value === "string" ? value.trim() : value)),
|
|
30
|
+
__metadata("design:type", String)
|
|
31
|
+
], LoginCustomerDto.prototype, "email", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, swagger_1.ApiProperty)({
|
|
34
|
+
example: "StrongP@ssw0rd",
|
|
35
|
+
description: "Plain text password to authenticate",
|
|
36
|
+
}),
|
|
37
|
+
(0, class_validator_1.IsString)(),
|
|
38
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
39
|
+
(0, class_validator_1.MaxLength)(72) // bcrypt only processes first 72 bytes; anything longer is a DoS attempt
|
|
40
|
+
,
|
|
41
|
+
__metadata("design:type", String)
|
|
42
|
+
], LoginCustomerDto.prototype, "password", void 0);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { LoginDetailData } from "./login-details.entity";
|
|
2
|
+
export declare class LoginCustomerDetailsEntity {
|
|
3
|
+
id: number;
|
|
4
|
+
customer_user_id: number;
|
|
5
|
+
date: Date;
|
|
6
|
+
login_data: LoginDetailData[];
|
|
7
|
+
email: string;
|
|
8
|
+
first_name: string;
|
|
9
|
+
last_name: string;
|
|
10
|
+
total_logins: number;
|
|
11
|
+
successful_logins: number;
|
|
12
|
+
failed_logins: number;
|
|
13
|
+
created_at: Date;
|
|
14
|
+
updated_at: Date;
|
|
15
|
+
deleted_at: Date;
|
|
16
|
+
created_by: number;
|
|
17
|
+
updated_by: number;
|
|
18
|
+
deleted_by: number;
|
|
19
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.LoginCustomerDetailsEntity = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
let LoginCustomerDetailsEntity = class LoginCustomerDetailsEntity {
|
|
15
|
+
};
|
|
16
|
+
exports.LoginCustomerDetailsEntity = LoginCustomerDetailsEntity;
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, typeorm_1.PrimaryGeneratedColumn)(),
|
|
19
|
+
__metadata("design:type", Number)
|
|
20
|
+
], LoginCustomerDetailsEntity.prototype, "id", void 0);
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, typeorm_1.Column)({ type: "int", nullable: false }),
|
|
23
|
+
__metadata("design:type", Number)
|
|
24
|
+
], LoginCustomerDetailsEntity.prototype, "customer_user_id", void 0);
|
|
25
|
+
__decorate([
|
|
26
|
+
(0, typeorm_1.Column)({ type: "date", nullable: false }),
|
|
27
|
+
__metadata("design:type", Date)
|
|
28
|
+
], LoginCustomerDetailsEntity.prototype, "date", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, typeorm_1.Column)({
|
|
31
|
+
name: "login_data",
|
|
32
|
+
type: "json",
|
|
33
|
+
nullable: true,
|
|
34
|
+
comment: "JSON array of login details for the date",
|
|
35
|
+
}),
|
|
36
|
+
__metadata("design:type", Array)
|
|
37
|
+
], LoginCustomerDetailsEntity.prototype, "login_data", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, typeorm_1.Column)({ length: 250, nullable: true }),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], LoginCustomerDetailsEntity.prototype, "email", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, typeorm_1.Column)({ length: 100, nullable: true }),
|
|
44
|
+
__metadata("design:type", String)
|
|
45
|
+
], LoginCustomerDetailsEntity.prototype, "first_name", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, typeorm_1.Column)({ length: 100, nullable: true }),
|
|
48
|
+
__metadata("design:type", String)
|
|
49
|
+
], LoginCustomerDetailsEntity.prototype, "last_name", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, typeorm_1.Column)({ type: "int", nullable: true }),
|
|
52
|
+
__metadata("design:type", Number)
|
|
53
|
+
], LoginCustomerDetailsEntity.prototype, "total_logins", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
(0, typeorm_1.Column)({ type: "int", nullable: true }),
|
|
56
|
+
__metadata("design:type", Number)
|
|
57
|
+
], LoginCustomerDetailsEntity.prototype, "successful_logins", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, typeorm_1.Column)({ type: "int", nullable: true }),
|
|
60
|
+
__metadata("design:type", Number)
|
|
61
|
+
], LoginCustomerDetailsEntity.prototype, "failed_logins", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, typeorm_1.CreateDateColumn)({ type: "timestamp" }),
|
|
64
|
+
__metadata("design:type", Date)
|
|
65
|
+
], LoginCustomerDetailsEntity.prototype, "created_at", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, typeorm_1.UpdateDateColumn)({ type: "timestamp", nullable: true }),
|
|
68
|
+
__metadata("design:type", Date)
|
|
69
|
+
], LoginCustomerDetailsEntity.prototype, "updated_at", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
(0, typeorm_1.DeleteDateColumn)({ type: "timestamp", nullable: true }),
|
|
72
|
+
__metadata("design:type", Date)
|
|
73
|
+
], LoginCustomerDetailsEntity.prototype, "deleted_at", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
(0, typeorm_1.Column)({ type: "int", nullable: true }),
|
|
76
|
+
__metadata("design:type", Number)
|
|
77
|
+
], LoginCustomerDetailsEntity.prototype, "created_by", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
(0, typeorm_1.Column)({ type: "int", nullable: true }),
|
|
80
|
+
__metadata("design:type", Number)
|
|
81
|
+
], LoginCustomerDetailsEntity.prototype, "updated_by", void 0);
|
|
82
|
+
__decorate([
|
|
83
|
+
(0, typeorm_1.Column)({ type: "int", nullable: true }),
|
|
84
|
+
__metadata("design:type", Number)
|
|
85
|
+
], LoginCustomerDetailsEntity.prototype, "deleted_by", void 0);
|
|
86
|
+
exports.LoginCustomerDetailsEntity = LoginCustomerDetailsEntity = __decorate([
|
|
87
|
+
(0, typeorm_1.Entity)("tbl_user_customer_login_details"),
|
|
88
|
+
(0, typeorm_1.Index)(["customer_user_id"]),
|
|
89
|
+
(0, typeorm_1.Index)(["date"]),
|
|
90
|
+
(0, typeorm_1.Index)(["customer_user_id", "date"])
|
|
91
|
+
], LoginCustomerDetailsEntity);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CustomerRole = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
let CustomerRole = class CustomerRole {
|
|
15
|
+
};
|
|
16
|
+
exports.CustomerRole = CustomerRole;
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, typeorm_1.PrimaryGeneratedColumn)("increment", { name: "id" }),
|
|
19
|
+
__metadata("design:type", Number)
|
|
20
|
+
], CustomerRole.prototype, "id", void 0);
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, typeorm_1.Column)({ name: "role_name", type: "varchar", length: 100, unique: true }),
|
|
23
|
+
__metadata("design:type", String)
|
|
24
|
+
], CustomerRole.prototype, "roleName", void 0);
|
|
25
|
+
__decorate([
|
|
26
|
+
(0, typeorm_1.Column)({
|
|
27
|
+
name: "role_description",
|
|
28
|
+
type: "varchar",
|
|
29
|
+
length: 255,
|
|
30
|
+
nullable: true,
|
|
31
|
+
}),
|
|
32
|
+
__metadata("design:type", String)
|
|
33
|
+
], CustomerRole.prototype, "roleDescription", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, typeorm_1.Column)({ name: "is_active", type: "boolean", default: true }),
|
|
36
|
+
__metadata("design:type", Boolean)
|
|
37
|
+
], CustomerRole.prototype, "isActive", void 0);
|
|
38
|
+
exports.CustomerRole = CustomerRole = __decorate([
|
|
39
|
+
(0, typeorm_1.Entity)({ name: "tbl_c_master_roles_customer" })
|
|
40
|
+
], CustomerRole);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare class UserCustomerLastLoginEntity {
|
|
2
|
+
id: number;
|
|
3
|
+
customer_user_id: number;
|
|
4
|
+
email: string;
|
|
5
|
+
first_name: string;
|
|
6
|
+
last_name: string;
|
|
7
|
+
ip_address: string;
|
|
8
|
+
ip_address_name?: string;
|
|
9
|
+
browser: string;
|
|
10
|
+
device_type: string;
|
|
11
|
+
operating_system: string;
|
|
12
|
+
user_agent: string;
|
|
13
|
+
location: string;
|
|
14
|
+
module_id: number;
|
|
15
|
+
login_status: "success" | "failed" | "blocked";
|
|
16
|
+
failure_reason: string;
|
|
17
|
+
session_duration_ms: number;
|
|
18
|
+
metadata: Record<string, any>;
|
|
19
|
+
login_time: Date;
|
|
20
|
+
logout_time: Date;
|
|
21
|
+
created_at: Date;
|
|
22
|
+
created_by: number;
|
|
23
|
+
updated_at: Date;
|
|
24
|
+
updated_by: number;
|
|
25
|
+
deleted_by: number;
|
|
26
|
+
deleted_at: Date;
|
|
27
|
+
}
|