ecrs-auth-core 1.0.103 → 1.0.105
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 +46 -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 +64 -0
- package/dist/auth-customer.service.js +323 -0
- package/dist/auth.service.js +19 -9
- 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/dtos/login.dto.js +6 -0
- package/dist/entities/login-details-customer.entity.d.ts +34 -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.entity.d.ts +27 -0
- package/dist/entities/user-customer.entity.js +120 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +6 -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 +14 -0
- package/dist/jwt/jwt-customer.strategy.js +57 -0
- package/package.json +1 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Request } from "express";
|
|
2
|
+
import { JwtService } from "@nestjs/jwt";
|
|
3
|
+
import { AuthCustomerService } from "./auth-customer.service";
|
|
4
|
+
import { LoginCustomerDto } from "./dtos/login-customer.dto";
|
|
5
|
+
export declare class AuthCustomerController {
|
|
6
|
+
private readonly authCustomerService;
|
|
7
|
+
private readonly jwtService;
|
|
8
|
+
constructor(authCustomerService: AuthCustomerService, jwtService: JwtService);
|
|
9
|
+
login(request: Request, body: LoginCustomerDto): Promise<{
|
|
10
|
+
status: boolean;
|
|
11
|
+
message: string;
|
|
12
|
+
data: {
|
|
13
|
+
user: {
|
|
14
|
+
id: number;
|
|
15
|
+
email: string;
|
|
16
|
+
roleId: number;
|
|
17
|
+
roleName: string | null;
|
|
18
|
+
tokenVersion: number;
|
|
19
|
+
name: string;
|
|
20
|
+
firstName: string;
|
|
21
|
+
lastName: string;
|
|
22
|
+
mobileNo: number;
|
|
23
|
+
userImage: string;
|
|
24
|
+
referenceId: number;
|
|
25
|
+
parentId: number;
|
|
26
|
+
lastLoginTime: Date | null;
|
|
27
|
+
is_reset_password: number;
|
|
28
|
+
profile_photo_url: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
access_token: string;
|
|
32
|
+
}>;
|
|
33
|
+
logout(request: any): Promise<{
|
|
34
|
+
status: boolean;
|
|
35
|
+
message: string;
|
|
36
|
+
data: {
|
|
37
|
+
user: {
|
|
38
|
+
id: any;
|
|
39
|
+
logoutTime: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
}>;
|
|
43
|
+
private extractClientData;
|
|
44
|
+
private parseUserAgent;
|
|
45
|
+
private getClientIp;
|
|
46
|
+
}
|
|
@@ -0,0 +1,249 @@
|
|
|
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
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AuthCustomerController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const jwt_1 = require("@nestjs/jwt");
|
|
18
|
+
const auth_customer_service_1 = require("./auth-customer.service");
|
|
19
|
+
const login_customer_dto_1 = require("./dtos/login-customer.dto");
|
|
20
|
+
const login_response_dto_1 = require("./dtos/login-response.dto");
|
|
21
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
22
|
+
let AuthCustomerController = class AuthCustomerController {
|
|
23
|
+
constructor(authCustomerService, jwtService) {
|
|
24
|
+
this.authCustomerService = authCustomerService;
|
|
25
|
+
this.jwtService = jwtService;
|
|
26
|
+
}
|
|
27
|
+
async login(request, body) {
|
|
28
|
+
const clientIp = this.getClientIp(request);
|
|
29
|
+
const userAgent = request.get("user-agent") || "Unknown";
|
|
30
|
+
const additionalData = this.extractClientData(request, userAgent);
|
|
31
|
+
console.log(`📍 Customer Emplyee login attempt from IP: ${clientIp}, User-Agent: ${userAgent}`);
|
|
32
|
+
const user = await this.authCustomerService.validateUser(body.email, body.password, clientIp);
|
|
33
|
+
if (!user) {
|
|
34
|
+
await this.authCustomerService
|
|
35
|
+
.saveLastLogin({ email: body.email }, clientIp, "failed", "Invalid credentials or IP not allowed", additionalData)
|
|
36
|
+
.catch((err) => console.error("❌ Error saving failed customer login to tbl_user_last_login:", err.message));
|
|
37
|
+
await this.authCustomerService
|
|
38
|
+
.saveLoginDetailsJson({ email: body.email }, clientIp, "failed", "Invalid credentials or IP not allowed", additionalData)
|
|
39
|
+
.catch((err) => console.error("❌ Error saving failed customer login to tbl_user_login_details:", err.message));
|
|
40
|
+
throw new common_1.UnauthorizedException("Login failed: email or password not matched or IP not allowed");
|
|
41
|
+
}
|
|
42
|
+
console.log(`✅ Customer ${body.email} authenticated successfully`);
|
|
43
|
+
const loginResponse = await this.authCustomerService.login(user);
|
|
44
|
+
console.log(`✅ Customer ${body.email} logged in successfully to Customer Domain`);
|
|
45
|
+
await this.authCustomerService
|
|
46
|
+
.saveLastLogin(user, clientIp, "success", undefined, {
|
|
47
|
+
...additionalData,
|
|
48
|
+
})
|
|
49
|
+
.catch((err) => console.error("❌ Error saving successful customer login to tbl_user_last_login:", err.message));
|
|
50
|
+
await this.authCustomerService
|
|
51
|
+
.saveLoginDetailsJson(user, clientIp, "success", undefined, {
|
|
52
|
+
...additionalData,
|
|
53
|
+
})
|
|
54
|
+
.catch((err) => console.error("❌ Error saving successful customer login to tbl_user_login_details:", err.message));
|
|
55
|
+
return loginResponse;
|
|
56
|
+
}
|
|
57
|
+
async logout(request) {
|
|
58
|
+
const authHeader = request.headers.authorization;
|
|
59
|
+
if (!authHeader || !authHeader.startsWith("Bearer ")) {
|
|
60
|
+
throw new common_1.UnauthorizedException("Missing or invalid Authorization header. Required format: Bearer <token>");
|
|
61
|
+
}
|
|
62
|
+
const token = authHeader.substring(7);
|
|
63
|
+
try {
|
|
64
|
+
const payload = this.jwtService.verify(token);
|
|
65
|
+
const userId = payload.id;
|
|
66
|
+
if (!userId) {
|
|
67
|
+
throw new common_1.UnauthorizedException("Invalid token - no user ID found");
|
|
68
|
+
}
|
|
69
|
+
console.log(`🚪 Customer logout request for user ${userId}`);
|
|
70
|
+
await Promise.all([
|
|
71
|
+
this.authCustomerService
|
|
72
|
+
.updateLastLoginLogout(userId)
|
|
73
|
+
.catch((err) => console.error("❌ Error updating customer logout in tbl_user_last_login:", err.message)),
|
|
74
|
+
this.authCustomerService
|
|
75
|
+
.updateLoginLogoutDetailsJson(userId)
|
|
76
|
+
.catch((err) => console.error("❌ Error updating customer logout in tbl_user_login_details:", err.message)),
|
|
77
|
+
]);
|
|
78
|
+
console.log(`✅ Customer ${userId} logged out successfully`);
|
|
79
|
+
return {
|
|
80
|
+
status: true,
|
|
81
|
+
message: "Logout successful",
|
|
82
|
+
data: { user: { id: userId, logoutTime: new Date().toISOString() } },
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
if (error.name === "TokenExpiredError")
|
|
87
|
+
throw new common_1.UnauthorizedException("JWT token has expired");
|
|
88
|
+
if (error.name === "JsonWebTokenError")
|
|
89
|
+
throw new common_1.UnauthorizedException("Invalid JWT token");
|
|
90
|
+
console.error("❌ Error during customer logout:", error?.message || error);
|
|
91
|
+
throw new common_1.UnauthorizedException("Logout failed");
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
extractClientData(request, userAgent) {
|
|
95
|
+
const { browser, os, deviceType } = this.parseUserAgent(userAgent);
|
|
96
|
+
const ipAddressName = request.get("x-forwarded-host") || request.get("host") || "Unknown";
|
|
97
|
+
const location = request.get("cf-ipcountry") || "Unknown";
|
|
98
|
+
return {
|
|
99
|
+
browser,
|
|
100
|
+
deviceType,
|
|
101
|
+
operatingSystem: os,
|
|
102
|
+
userAgent,
|
|
103
|
+
location,
|
|
104
|
+
ipAddressName,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
parseUserAgent(userAgent) {
|
|
108
|
+
const ua = userAgent.toLowerCase();
|
|
109
|
+
let browser = "Unknown";
|
|
110
|
+
if (ua.includes("chrome"))
|
|
111
|
+
browser = "Chrome";
|
|
112
|
+
else if (ua.includes("firefox"))
|
|
113
|
+
browser = "Firefox";
|
|
114
|
+
else if (ua.includes("safari"))
|
|
115
|
+
browser = "Safari";
|
|
116
|
+
else if (ua.includes("edg/"))
|
|
117
|
+
browser = "Edge";
|
|
118
|
+
else if (ua.includes("opera") || ua.includes("opr/"))
|
|
119
|
+
browser = "Opera";
|
|
120
|
+
else if (ua.includes("trident"))
|
|
121
|
+
browser = "Internet Explorer";
|
|
122
|
+
let os = "Unknown";
|
|
123
|
+
if (ua.includes("windows"))
|
|
124
|
+
os = "Windows";
|
|
125
|
+
else if (ua.includes("mac"))
|
|
126
|
+
os = "macOS";
|
|
127
|
+
else if (ua.includes("linux"))
|
|
128
|
+
os = "Linux";
|
|
129
|
+
else if (ua.includes("iphone") || ua.includes("ipad"))
|
|
130
|
+
os = "iOS";
|
|
131
|
+
else if (ua.includes("android"))
|
|
132
|
+
os = "Android";
|
|
133
|
+
let deviceType = "Desktop";
|
|
134
|
+
if (ua.includes("mobile") ||
|
|
135
|
+
ua.includes("android") ||
|
|
136
|
+
ua.includes("iphone"))
|
|
137
|
+
deviceType = "Mobile";
|
|
138
|
+
else if (ua.includes("tablet") || ua.includes("ipad"))
|
|
139
|
+
deviceType = "Tablet";
|
|
140
|
+
return { browser, os, deviceType };
|
|
141
|
+
}
|
|
142
|
+
getClientIp(request) {
|
|
143
|
+
let ip = "";
|
|
144
|
+
const xForwardedFor = request.headers["x-forwarded-for"];
|
|
145
|
+
if (xForwardedFor) {
|
|
146
|
+
const ips = Array.isArray(xForwardedFor)
|
|
147
|
+
? xForwardedFor
|
|
148
|
+
: xForwardedFor.split(",");
|
|
149
|
+
ip = ips[0].trim();
|
|
150
|
+
}
|
|
151
|
+
else if (request.headers["x-real-ip"]) {
|
|
152
|
+
const xRealIp = request.headers["x-real-ip"];
|
|
153
|
+
ip = Array.isArray(xRealIp) ? xRealIp[0] : xRealIp;
|
|
154
|
+
}
|
|
155
|
+
else if (request.headers["cf-connecting-ip"]) {
|
|
156
|
+
const cfIp = request.headers["cf-connecting-ip"];
|
|
157
|
+
ip = Array.isArray(cfIp) ? cfIp[0] : cfIp;
|
|
158
|
+
}
|
|
159
|
+
else if (request.ip) {
|
|
160
|
+
ip = request.ip;
|
|
161
|
+
}
|
|
162
|
+
else if (request.socket.remoteAddress) {
|
|
163
|
+
ip = request.socket.remoteAddress;
|
|
164
|
+
}
|
|
165
|
+
if (ip.startsWith("::ffff:"))
|
|
166
|
+
ip = ip.substring(7);
|
|
167
|
+
return ip || "Unknown";
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
exports.AuthCustomerController = AuthCustomerController;
|
|
171
|
+
__decorate([
|
|
172
|
+
(0, common_1.Post)("login"),
|
|
173
|
+
(0, common_1.HttpCode)(200),
|
|
174
|
+
(0, swagger_1.ApiBody)({
|
|
175
|
+
required: true,
|
|
176
|
+
description: "Credentials required for customer authentication",
|
|
177
|
+
schema: {
|
|
178
|
+
$ref: (0, swagger_1.getSchemaPath)(login_customer_dto_1.LoginCustomerDto),
|
|
179
|
+
example: {
|
|
180
|
+
email: "customer@example.com",
|
|
181
|
+
password: "StrongP@ssw0rd",
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
}),
|
|
185
|
+
(0, swagger_1.ApiOperation)({
|
|
186
|
+
summary: "Customer login",
|
|
187
|
+
description: "Authenticate customer user from tbl_users_customer and return access token",
|
|
188
|
+
}),
|
|
189
|
+
(0, swagger_1.ApiOkResponse)({
|
|
190
|
+
description: "Login successful",
|
|
191
|
+
schema: {
|
|
192
|
+
$ref: (0, swagger_1.getSchemaPath)(login_response_dto_1.LoginResponseDto),
|
|
193
|
+
example: {
|
|
194
|
+
status: true,
|
|
195
|
+
message: "Login successful",
|
|
196
|
+
data: {
|
|
197
|
+
user: {
|
|
198
|
+
id: 1,
|
|
199
|
+
email: "customer@example.com",
|
|
200
|
+
roleId: 5,
|
|
201
|
+
roleName: "CUSTOMER_BOOKER",
|
|
202
|
+
moduleId: 7,
|
|
203
|
+
name: "Jane Doe",
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
access_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
}),
|
|
210
|
+
(0, swagger_1.ApiUnauthorizedResponse)({
|
|
211
|
+
description: "Invalid credentials or IP not allowed",
|
|
212
|
+
}),
|
|
213
|
+
__param(0, (0, common_1.Req)()),
|
|
214
|
+
__param(1, (0, common_1.Body)()),
|
|
215
|
+
__metadata("design:type", Function),
|
|
216
|
+
__metadata("design:paramtypes", [Object, login_customer_dto_1.LoginCustomerDto]),
|
|
217
|
+
__metadata("design:returntype", Promise)
|
|
218
|
+
], AuthCustomerController.prototype, "login", null);
|
|
219
|
+
__decorate([
|
|
220
|
+
(0, common_1.Post)("logout"),
|
|
221
|
+
(0, common_1.HttpCode)(200),
|
|
222
|
+
(0, swagger_1.ApiOperation)({
|
|
223
|
+
summary: "Customer logout",
|
|
224
|
+
description: "Logout customer user and update session end time.",
|
|
225
|
+
}),
|
|
226
|
+
(0, swagger_1.ApiOkResponse)({
|
|
227
|
+
description: "Logout successful",
|
|
228
|
+
example: {
|
|
229
|
+
status: true,
|
|
230
|
+
message: "Logout successful",
|
|
231
|
+
data: { user: { id: 1, logoutTime: "2026-01-28T10:30:00.000Z" } },
|
|
232
|
+
},
|
|
233
|
+
}),
|
|
234
|
+
(0, swagger_1.ApiUnauthorizedResponse)({
|
|
235
|
+
description: "Unauthorized - Invalid or missing JWT token",
|
|
236
|
+
}),
|
|
237
|
+
__param(0, (0, common_1.Req)()),
|
|
238
|
+
__metadata("design:type", Function),
|
|
239
|
+
__metadata("design:paramtypes", [Object]),
|
|
240
|
+
__metadata("design:returntype", Promise)
|
|
241
|
+
], AuthCustomerController.prototype, "logout", null);
|
|
242
|
+
exports.AuthCustomerController = AuthCustomerController = __decorate([
|
|
243
|
+
(0, swagger_1.ApiTags)("auth-customer"),
|
|
244
|
+
(0, swagger_1.ApiBearerAuth)(),
|
|
245
|
+
(0, swagger_1.ApiExtraModels)(login_customer_dto_1.LoginCustomerDto, login_response_dto_1.LoginResponseDto),
|
|
246
|
+
(0, common_1.Controller)("auth-customer"),
|
|
247
|
+
__metadata("design:paramtypes", [auth_customer_service_1.AuthCustomerService,
|
|
248
|
+
jwt_1.JwtService])
|
|
249
|
+
], AuthCustomerController);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import { AuthCustomerCoreOptions } from './interfaces/auth-customer-options.interface';
|
|
3
|
+
export declare class AuthCustomerCoreModule {
|
|
4
|
+
static registerAsync(options: {
|
|
5
|
+
inject: any[];
|
|
6
|
+
useFactory: (...args: any[]) => Promise<AuthCustomerCoreOptions>;
|
|
7
|
+
}): DynamicModule;
|
|
8
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
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 AuthCustomerCoreModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.AuthCustomerCoreModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const jwt_1 = require("@nestjs/jwt");
|
|
13
|
+
const auth_customer_service_1 = require("./auth-customer.service");
|
|
14
|
+
const auth_customer_controller_1 = require("./auth-customer.controller");
|
|
15
|
+
const jwt_customer_strategy_1 = require("./jwt/jwt-customer.strategy");
|
|
16
|
+
const jwt_customer_guard_1 = require("./jwt/jwt-customer.guard");
|
|
17
|
+
const constants_1 = require("./constants/constants");
|
|
18
|
+
let AuthCustomerCoreModule = AuthCustomerCoreModule_1 = class AuthCustomerCoreModule {
|
|
19
|
+
static registerAsync(options) {
|
|
20
|
+
const asyncProvider = {
|
|
21
|
+
provide: constants_1.AUTH_CUSTOMER_CORE_OPTIONS,
|
|
22
|
+
inject: options.inject,
|
|
23
|
+
useFactory: options.useFactory,
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
module: AuthCustomerCoreModule_1,
|
|
27
|
+
imports: [
|
|
28
|
+
jwt_1.JwtModule.registerAsync({
|
|
29
|
+
inject: options.inject,
|
|
30
|
+
useFactory: async (...args) => {
|
|
31
|
+
const config = await options.useFactory(...args);
|
|
32
|
+
console.log('🔐 JWT Secret from AUTH_CUSTOMER_CORE_OPTIONS:', config.jwtSecret);
|
|
33
|
+
console.log('⏳ JWT Expiry:', config.jwtExpiresIn);
|
|
34
|
+
return {
|
|
35
|
+
secret: config.jwtSecret,
|
|
36
|
+
signOptions: { expiresIn: config.jwtExpiresIn },
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
}),
|
|
40
|
+
],
|
|
41
|
+
providers: [
|
|
42
|
+
asyncProvider,
|
|
43
|
+
auth_customer_service_1.AuthCustomerService,
|
|
44
|
+
jwt_customer_strategy_1.JwtCustomerStrategy,
|
|
45
|
+
jwt_customer_guard_1.JwtCustomerAuthGuard,
|
|
46
|
+
],
|
|
47
|
+
controllers: [auth_customer_controller_1.AuthCustomerController],
|
|
48
|
+
exports: [
|
|
49
|
+
constants_1.AUTH_CUSTOMER_CORE_OPTIONS,
|
|
50
|
+
jwt_1.JwtModule,
|
|
51
|
+
auth_customer_service_1.AuthCustomerService,
|
|
52
|
+
jwt_customer_strategy_1.JwtCustomerStrategy,
|
|
53
|
+
jwt_customer_guard_1.JwtCustomerAuthGuard,
|
|
54
|
+
],
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
exports.AuthCustomerCoreModule = AuthCustomerCoreModule;
|
|
59
|
+
exports.AuthCustomerCoreModule = AuthCustomerCoreModule = AuthCustomerCoreModule_1 = __decorate([
|
|
60
|
+
(0, common_1.Global)(),
|
|
61
|
+
(0, common_1.Module)({})
|
|
62
|
+
], AuthCustomerCoreModule);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { JwtService } from "@nestjs/jwt";
|
|
2
|
+
import { AuthCustomerCoreOptions } from "./interfaces/auth-customer-options.interface";
|
|
3
|
+
import { UserCustomer } from "./entities/user-customer.entity";
|
|
4
|
+
export declare class AuthCustomerService {
|
|
5
|
+
private readonly jwtService;
|
|
6
|
+
private readonly options;
|
|
7
|
+
private readonly userRepo;
|
|
8
|
+
private readonly roleRepo;
|
|
9
|
+
private readonly moduleAccessRepo;
|
|
10
|
+
private readonly userLastLoginRepo;
|
|
11
|
+
private readonly loginDetailsRepo;
|
|
12
|
+
private readonly employeeWorkProfileRepo;
|
|
13
|
+
private uploadPhotoDir;
|
|
14
|
+
constructor(jwtService: JwtService, options: AuthCustomerCoreOptions);
|
|
15
|
+
validateUser(email: string, password: string, clientIp?: string): Promise<UserCustomer>;
|
|
16
|
+
hasModuleAccess(userId: number, moduleId: number): Promise<boolean>;
|
|
17
|
+
saveLastLogin(user: UserCustomer, clientIp: string, loginStatus?: "success" | "failed" | "blocked", failureReason?: string, additionalData?: {
|
|
18
|
+
browser?: string;
|
|
19
|
+
deviceType?: string;
|
|
20
|
+
operatingSystem?: string;
|
|
21
|
+
userAgent?: string;
|
|
22
|
+
location?: string;
|
|
23
|
+
moduleId?: number;
|
|
24
|
+
ipAddressName?: string;
|
|
25
|
+
metadata?: Record<string, any>;
|
|
26
|
+
}): Promise<void>;
|
|
27
|
+
saveLoginDetailsJson(user: UserCustomer, clientIp: string, loginStatus?: "success" | "failed" | "blocked", failureReason?: string, additionalData?: {
|
|
28
|
+
browser?: string;
|
|
29
|
+
deviceType?: string;
|
|
30
|
+
operatingSystem?: string;
|
|
31
|
+
userAgent?: string;
|
|
32
|
+
location?: string;
|
|
33
|
+
moduleId?: number;
|
|
34
|
+
ipAddressName?: string;
|
|
35
|
+
metadata?: Record<string, any>;
|
|
36
|
+
}): Promise<void>;
|
|
37
|
+
updateLoginLogoutDetailsJson(userId: number): Promise<void>;
|
|
38
|
+
updateLastLoginLogout(userId: number): Promise<void>;
|
|
39
|
+
login(user: UserCustomer): Promise<{
|
|
40
|
+
status: boolean;
|
|
41
|
+
message: string;
|
|
42
|
+
data: {
|
|
43
|
+
user: {
|
|
44
|
+
id: number;
|
|
45
|
+
email: string;
|
|
46
|
+
roleId: number;
|
|
47
|
+
roleName: string | null;
|
|
48
|
+
tokenVersion: number;
|
|
49
|
+
name: string;
|
|
50
|
+
firstName: string;
|
|
51
|
+
lastName: string;
|
|
52
|
+
mobileNo: number;
|
|
53
|
+
userImage: string;
|
|
54
|
+
referenceId: number;
|
|
55
|
+
parentId: number;
|
|
56
|
+
lastLoginTime: Date | null;
|
|
57
|
+
is_reset_password: number;
|
|
58
|
+
profile_photo_url: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
access_token: string;
|
|
62
|
+
}>;
|
|
63
|
+
findUserById(id: number): Promise<UserCustomer | null>;
|
|
64
|
+
}
|