propro-utils 1.3.32 → 1.3.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/middlewares/account_info.js +6 -3
- package/package.json +1 -3
- package/src/index.js +2 -2
|
@@ -2,8 +2,7 @@ require("dotenv").config();
|
|
|
2
2
|
const axios = require("axios");
|
|
3
3
|
const {getOrSetCache} = require("../utils/redis");
|
|
4
4
|
const { v4: uuidv4 } = require('uuid');
|
|
5
|
-
|
|
6
|
-
const { Client } = require('redis');
|
|
5
|
+
|
|
7
6
|
/**
|
|
8
7
|
* Retrieves the account profile data from the authentication server and caches it using Redis.
|
|
9
8
|
* If the profile data is not found in the cache, it fetches it from the authentication server and stores it in the cache.
|
|
@@ -62,7 +61,11 @@ const getAccountProfile = async (redisClient, userSchema, accountId) => {
|
|
|
62
61
|
const checkIfUserExists = async (userSchema, accountId) => {
|
|
63
62
|
const user = await userSchema.findOne({ accountId });
|
|
64
63
|
if (!user) {
|
|
65
|
-
await userSchema.create({
|
|
64
|
+
await userSchema.create({
|
|
65
|
+
accountId,
|
|
66
|
+
id: uuidv4(),
|
|
67
|
+
verified: false,
|
|
68
|
+
});
|
|
66
69
|
}
|
|
67
70
|
};
|
|
68
71
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "propro-utils",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.34",
|
|
4
4
|
"description": "Auth middleware for propro-auth",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -61,12 +61,10 @@
|
|
|
61
61
|
"axios": "^1.6.1",
|
|
62
62
|
"dotenv": "^16.4.1",
|
|
63
63
|
"express-rate-limit": "^7.1.4",
|
|
64
|
-
"mongoose": "^8.1.1",
|
|
65
64
|
"nodemailer": "^6.9.7",
|
|
66
65
|
"nodemailer-mailgun-transport": "^2.1.5",
|
|
67
66
|
"querystring": "^0.2.1",
|
|
68
67
|
"react-email": "^1.9.5",
|
|
69
|
-
"redis": "^4.6.12",
|
|
70
68
|
"uuid": "^9.0.1"
|
|
71
69
|
}
|
|
72
70
|
}
|
package/src/index.js
CHANGED
|
@@ -21,7 +21,7 @@ let _serverAuth, _clientAuth;
|
|
|
21
21
|
* validateUser: async (userId) => { }, // Function to validate user
|
|
22
22
|
* onAuthFailRedirect: '/login', // URL to redirect on authentication failure
|
|
23
23
|
* additionalChecks: async (req) => { }, // Additional custom checks for requests
|
|
24
|
-
* }
|
|
24
|
+
* },
|
|
25
25
|
* @param {boolean} [options.useClientAuth=false] - A boolean flag to enable client-side authentication.
|
|
26
26
|
* @param {Object} [options.clientOptions={}] - Configuration options for client-side authentication.
|
|
27
27
|
* @param {Schema} [userSchema] - The user schema to perform the operations on.
|
|
@@ -39,7 +39,7 @@ let _serverAuth, _clientAuth;
|
|
|
39
39
|
* additionalChecks: async (req) => { },
|
|
40
40
|
* },
|
|
41
41
|
* useClientAuth: false,
|
|
42
|
-
* }));
|
|
42
|
+
* }, UserSchema));
|
|
43
43
|
*/
|
|
44
44
|
module.exports = function proproAuthMiddleware(options = {}, userSchema) {
|
|
45
45
|
validateEnvironmentVariables([
|