propro-utils 1.5.11 → 1.5.13

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.
@@ -66,14 +66,22 @@ const getAccountProfile = async (redisClient, userSchema, accountId) => {
66
66
  * @returns {Promise<user>} - A promise that resolves once the check/create operation is done.
67
67
  */
68
68
  const checkIfUserExists = async (userSchema, accountId) => {
69
+ console.log('accountId', accountId);
69
70
  const user = await userSchema.findOne({ accountId });
71
+ console.log('user', user);
70
72
  if (!user) {
71
- await userSchema.create({
72
- accountId,
73
- id: uuidv4(),
74
- verified: false,
75
- });
73
+ try {
74
+ const user = await userSchema.create({
75
+ accountId,
76
+ id: uuidv4(),
77
+ verified: false,
78
+ });
79
+ return user;
80
+ } catch (error) {
81
+ throw new Error('Error creating user');
82
+ }
76
83
  }
84
+ console.log('user', user);
77
85
  return user;
78
86
  };
79
87
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "propro-utils",
3
- "version": "1.5.11",
3
+ "version": "1.5.13",
4
4
  "description": "Auth middleware for propro-auth",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -328,7 +328,7 @@ class AuthMiddleware {
328
328
 
329
329
  proxyToAuthServer = async (req, path) => {
330
330
  let accessToken = null;
331
- if (this.pathRequiresAccessToken(path)) {
331
+ if (!this.pathRequiresAccessToken(path)) {
332
332
  console.log('path requires access token');
333
333
  accessToken = req.cookies['x-access-token'];
334
334
  if (!accessToken) {