@culturefy/shared 1.0.32 → 1.0.33
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/build/cjs/middlewares/token-validation.js +4 -2
- package/build/cjs/middlewares/token-validation.js.map +1 -1
- package/build/cjs/models/user.model.js +272 -366
- package/build/cjs/models/user.model.js.map +1 -1
- package/build/cjs/service/user.service.js +89 -84
- package/build/cjs/service/user.service.js.map +1 -1
- package/build/esm/middlewares/token-validation.js +4 -2
- package/build/esm/middlewares/token-validation.js.map +1 -1
- package/build/esm/models/user.model.js +272 -366
- package/build/esm/models/user.model.js.map +1 -1
- package/build/esm/service/user.service.js +89 -85
- package/build/esm/service/user.service.js.map +1 -1
- package/build/src/middlewares/token-validation.js +4 -2
- package/build/src/middlewares/token-validation.js.map +1 -1
- package/build/src/models/user.model.d.ts +0 -5
- package/build/src/models/user.model.js +266 -263
- package/build/src/models/user.model.js.map +1 -1
- package/build/src/service/user.service.d.ts +0 -6
- package/build/src/service/user.service.js +1 -107
- package/build/src/service/user.service.js.map +1 -1
- package/package.json +1 -1
- package/src/middlewares/token-validation.ts +4 -2
- package/src/models/user.model.ts +265 -265
- package/src/service/user.service.ts +79 -77
|
@@ -1,118 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UserService = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const mongoose_1 = require("mongoose");
|
|
6
|
-
const user_model_1 = require("../models/user.model");
|
|
7
4
|
const shared_1 = require("@culturefy/shared");
|
|
8
5
|
class UserService extends shared_1.Initializers {
|
|
6
|
+
// private readonly schema = UserModel.schema;
|
|
9
7
|
constructor(context, dbUrl) {
|
|
10
8
|
super(context, dbUrl);
|
|
11
|
-
this.schema = user_model_1.UserModel.schema;
|
|
12
|
-
}
|
|
13
|
-
getModel() {
|
|
14
|
-
const connection = this.getConnection();
|
|
15
|
-
if (!connection) {
|
|
16
|
-
throw new Error('Database connection not established');
|
|
17
|
-
}
|
|
18
|
-
return connection.model(user_model_1.UserModel.modelName, this.schema);
|
|
19
|
-
}
|
|
20
|
-
getUserById(userId) {
|
|
21
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
try {
|
|
23
|
-
let model = this.getModel();
|
|
24
|
-
this.context.log("UserId:", JSON.stringify(userId));
|
|
25
|
-
// Handle both string and SchemaObjectId inputs
|
|
26
|
-
let objectId;
|
|
27
|
-
if (typeof userId === 'string') {
|
|
28
|
-
objectId = new mongoose_1.Types.ObjectId(userId);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
// If it's already a SchemaObjectId, extract the string value
|
|
32
|
-
const userIdString = userId.path || userId.toString();
|
|
33
|
-
objectId = new mongoose_1.Types.ObjectId(userIdString);
|
|
34
|
-
}
|
|
35
|
-
this.context.log("ObjectId:", JSON.stringify(objectId));
|
|
36
|
-
const user = yield model.findById(objectId);
|
|
37
|
-
this.context.log("User:", JSON.stringify(user));
|
|
38
|
-
return user;
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
this.context.error("Error in getUserById", error);
|
|
42
|
-
throw error;
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
getUserByBusinessId(businessId, email) {
|
|
47
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
try {
|
|
49
|
-
let model = this.getModel();
|
|
50
|
-
this.context.log("BusinessId:", JSON.stringify(businessId));
|
|
51
|
-
this.context.log("Email:", JSON.stringify(email));
|
|
52
|
-
if (!businessId)
|
|
53
|
-
return null;
|
|
54
|
-
if (!email)
|
|
55
|
-
return null;
|
|
56
|
-
businessId = businessId.toLowerCase();
|
|
57
|
-
businessId = businessId.trim();
|
|
58
|
-
email = email.toLowerCase();
|
|
59
|
-
email = email.trim();
|
|
60
|
-
// Handle both string and SchemaObjectId inputs
|
|
61
|
-
let objectId;
|
|
62
|
-
if (typeof businessId === 'string') {
|
|
63
|
-
objectId = new mongoose_1.Types.ObjectId(businessId);
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
// If it's already a SchemaObjectId, extract the string value
|
|
67
|
-
const businessIdString = businessId.path || businessId.toString();
|
|
68
|
-
objectId = new mongoose_1.Types.ObjectId(businessIdString);
|
|
69
|
-
}
|
|
70
|
-
this.context.log("ObjectId:", JSON.stringify(objectId));
|
|
71
|
-
const user = yield model.findOne({ businessId: objectId, email: email });
|
|
72
|
-
this.context.log("User:", JSON.stringify(user));
|
|
73
|
-
return user;
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
this.context.error("Error in getUserByBusinessId", error);
|
|
77
|
-
throw error;
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
getUserByEmail(email) {
|
|
82
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
83
|
-
try {
|
|
84
|
-
let model = this.getModel();
|
|
85
|
-
this.context.log("Email:", JSON.stringify(email));
|
|
86
|
-
email = email.toLowerCase();
|
|
87
|
-
email = email.trim();
|
|
88
|
-
const user = yield model.findOne({ email: email });
|
|
89
|
-
this.context.log("User:", JSON.stringify(user));
|
|
90
|
-
return user;
|
|
91
|
-
}
|
|
92
|
-
catch (error) {
|
|
93
|
-
this.context.error("Error in getUserByEmail", error);
|
|
94
|
-
throw error;
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
9
|
}
|
|
98
10
|
}
|
|
99
11
|
exports.UserService = UserService;
|
|
100
|
-
tslib_1.__decorate([
|
|
101
|
-
shared_1.WithDb,
|
|
102
|
-
tslib_1.__metadata("design:type", Function),
|
|
103
|
-
tslib_1.__metadata("design:paramtypes", [String]),
|
|
104
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
105
|
-
], UserService.prototype, "getUserById", null);
|
|
106
|
-
tslib_1.__decorate([
|
|
107
|
-
shared_1.WithDb,
|
|
108
|
-
tslib_1.__metadata("design:type", Function),
|
|
109
|
-
tslib_1.__metadata("design:paramtypes", [String, String]),
|
|
110
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
111
|
-
], UserService.prototype, "getUserByBusinessId", null);
|
|
112
|
-
tslib_1.__decorate([
|
|
113
|
-
shared_1.WithDb,
|
|
114
|
-
tslib_1.__metadata("design:type", Function),
|
|
115
|
-
tslib_1.__metadata("design:paramtypes", [String]),
|
|
116
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
117
|
-
], UserService.prototype, "getUserByEmail", null);
|
|
118
12
|
//# sourceMappingURL=user.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.service.js","sourceRoot":"","sources":["../../../src/service/user.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"user.service.js","sourceRoot":"","sources":["../../../src/service/user.service.ts"],"names":[],"mappings":";;;AAKA,8CAAyD;AAEzD,MAAa,WAAY,SAAQ,qBAAY;IAEzC,8CAA8C;IAC9C,YAAY,OAA0B,EAAE,KAAY;QAChD,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC1B,CAAC;CAwFJ;AA7FD,kCA6FC"}
|
package/package.json
CHANGED
|
@@ -350,7 +350,8 @@ async function validateUserByRealm(
|
|
|
350
350
|
let user = null;
|
|
351
351
|
context.log("Getting user by realm:", realm);
|
|
352
352
|
try {
|
|
353
|
-
user = await userService.getUserByBusinessId(realm, email);
|
|
353
|
+
// user = await userService.getUserByBusinessId(realm, email);
|
|
354
|
+
user = '';
|
|
354
355
|
} catch (err: any) {
|
|
355
356
|
context.error(`Failed to get user by realm:`, err);
|
|
356
357
|
return { success: false, message: "User not found.." };
|
|
@@ -389,7 +390,8 @@ async function validateUserByEmail(
|
|
|
389
390
|
let user = null;
|
|
390
391
|
context.log("Getting user by email:", email);
|
|
391
392
|
try {
|
|
392
|
-
user = await userService.getUserByEmail(email);
|
|
393
|
+
// user = await userService.getUserByEmail(email);
|
|
394
|
+
user = '';
|
|
393
395
|
} catch (err: any) {
|
|
394
396
|
context.error(`Failed to get user by email:`, err);
|
|
395
397
|
return { success: false, message: "User not found.." };
|