@culturefy/shared 1.0.32 → 1.0.34
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/enums/secretKeys.enum.js +1 -0
- package/build/cjs/enums/secretKeys.enum.js.map +1 -1
- package/build/cjs/middlewares/token-validation.js +15 -462
- 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/enums/secretKeys.enum.js +1 -0
- package/build/esm/enums/secretKeys.enum.js.map +1 -1
- package/build/esm/middlewares/token-validation.js +16 -463
- 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/enums/secretKeys.enum.d.ts +2 -1
- package/build/src/enums/secretKeys.enum.js +1 -0
- package/build/src/enums/secretKeys.enum.js.map +1 -1
- package/build/src/middlewares/token-validation.d.ts +1 -1
- package/build/src/middlewares/token-validation.js +16 -314
- 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/enums/secretKeys.enum.ts +1 -0
- package/src/middlewares/token-validation.ts +19 -432
- package/src/models/user.model.ts +265 -265
- package/src/service/user.service.ts +79 -77
|
@@ -1,99 +1,101 @@
|
|
|
1
1
|
import { Types } from "mongoose";
|
|
2
2
|
import { InvocationContext } from "@azure/functions";
|
|
3
|
-
import IUser
|
|
3
|
+
import IUser
|
|
4
|
+
// { UserModel }
|
|
5
|
+
from "../models/user.model";
|
|
4
6
|
import { Initializers, WithDb } from "@culturefy/shared";
|
|
5
7
|
|
|
6
8
|
export class UserService extends Initializers {
|
|
7
9
|
|
|
8
|
-
private readonly schema = UserModel.schema;
|
|
10
|
+
// private readonly schema = UserModel.schema;
|
|
9
11
|
constructor(context: InvocationContext, dbUrl:string) {
|
|
10
12
|
super(context, dbUrl);
|
|
11
13
|
}
|
|
12
14
|
|
|
13
|
-
private getModel() {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
15
|
+
// private getModel() {
|
|
16
|
+
// const connection = (this as any).getConnection();
|
|
17
|
+
// if (!connection) {
|
|
18
|
+
// throw new Error('Database connection not established');
|
|
19
|
+
// }
|
|
20
|
+
// return connection.model(UserModel.modelName, this.schema);
|
|
21
|
+
// }
|
|
20
22
|
|
|
21
|
-
@WithDb
|
|
22
|
-
async getUserById(userId: string): Promise<IUser | null> {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
// @WithDb
|
|
24
|
+
// async getUserById(userId: string): Promise<IUser | null> {
|
|
25
|
+
// try {
|
|
26
|
+
// let model = this.getModel();
|
|
27
|
+
// this.context.log("UserId:", JSON.stringify(userId));
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
// // Handle both string and SchemaObjectId inputs
|
|
30
|
+
// let objectId: Types.ObjectId;
|
|
31
|
+
// if (typeof userId === 'string') {
|
|
32
|
+
// objectId = new Types.ObjectId(userId);
|
|
33
|
+
// } else {
|
|
34
|
+
// // If it's already a SchemaObjectId, extract the string value
|
|
35
|
+
// const userIdString = (userId as any).path || (userId as any).toString();
|
|
36
|
+
// objectId = new Types.ObjectId(userIdString);
|
|
37
|
+
// }
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
39
|
+
// this.context.log("ObjectId:", JSON.stringify(objectId));
|
|
40
|
+
// const user = await model.findById(objectId);
|
|
41
|
+
// this.context.log("User:", JSON.stringify(user));
|
|
42
|
+
// return user;
|
|
43
|
+
// } catch (error) {
|
|
44
|
+
// this.context.error("Error in getUserById", error);
|
|
45
|
+
// throw error;
|
|
46
|
+
// }
|
|
47
|
+
// }
|
|
46
48
|
|
|
47
|
-
@WithDb
|
|
48
|
-
async getUserByBusinessId(businessId: string, email: string): Promise<IUser | null> {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
// @WithDb
|
|
50
|
+
// async getUserByBusinessId(businessId: string, email: string): Promise<IUser | null> {
|
|
51
|
+
// try {
|
|
52
|
+
// let model = this.getModel();
|
|
53
|
+
// this.context.log("BusinessId:", JSON.stringify(businessId));
|
|
54
|
+
// this.context.log("Email:", JSON.stringify(email));
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
// if(!businessId) return null;
|
|
57
|
+
// if(!email) return null;
|
|
56
58
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
// businessId = businessId.toLowerCase();
|
|
60
|
+
// businessId = businessId.trim();
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
// email = email.toLowerCase();
|
|
63
|
+
// email = email.trim();
|
|
62
64
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
// // Handle both string and SchemaObjectId inputs
|
|
66
|
+
// let objectId: Types.ObjectId;
|
|
67
|
+
// if (typeof businessId === 'string') {
|
|
68
|
+
// objectId = new Types.ObjectId(businessId);
|
|
69
|
+
// } else {
|
|
70
|
+
// // If it's already a SchemaObjectId, extract the string value
|
|
71
|
+
// const businessIdString = (businessId as any).path || (businessId as any).toString();
|
|
72
|
+
// objectId = new Types.ObjectId(businessIdString);
|
|
73
|
+
// }
|
|
72
74
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
75
|
+
// this.context.log("ObjectId:", JSON.stringify(objectId));
|
|
76
|
+
// const user = await model.findOne({ businessId: objectId, email: email });
|
|
77
|
+
// this.context.log("User:", JSON.stringify(user));
|
|
78
|
+
// return user;
|
|
79
|
+
// } catch (error) {
|
|
80
|
+
// this.context.error("Error in getUserByBusinessId", error);
|
|
81
|
+
// throw error;
|
|
82
|
+
// }
|
|
83
|
+
// }
|
|
82
84
|
|
|
83
|
-
@WithDb
|
|
84
|
-
async getUserByEmail(email: string) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
// @WithDb
|
|
86
|
+
// async getUserByEmail(email: string) {
|
|
87
|
+
// try {
|
|
88
|
+
// let model = this.getModel();
|
|
89
|
+
// this.context.log("Email:", JSON.stringify(email));
|
|
88
90
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
91
|
+
// email = email.toLowerCase();
|
|
92
|
+
// email = email.trim();
|
|
93
|
+
// const user = await model.findOne({ email: email });
|
|
94
|
+
// this.context.log("User:", JSON.stringify(user));
|
|
95
|
+
// return user;
|
|
96
|
+
// } catch (error) {
|
|
97
|
+
// this.context.error("Error in getUserByEmail", error);
|
|
98
|
+
// throw error;
|
|
99
|
+
// }
|
|
100
|
+
// }
|
|
99
101
|
}
|