webortex-auth 1.0.1 → 1.0.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webortex-auth",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Reusable authentication package for Express + MongoDB with dependency injection",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -23,8 +23,8 @@
23
23
  "author": "WebOrtex",
24
24
  "license": "MIT",
25
25
  "peerDependencies": {
26
- "express": "^4.18.0 || ^5.0.0",
27
- "mongoose": "^7.0.0 || ^8.0.0"
26
+ "express": ">=4.0.0",
27
+ "mongoose": ">=6.0.0"
28
28
  },
29
29
  "dependencies": {
30
30
  "bcryptjs": "^2.4.3",
@@ -42,19 +42,14 @@ export const createUserModel = (mongoose) => {
42
42
  );
43
43
 
44
44
  // Hash password before saving
45
- userSchema.pre('save', async function (next) {
45
+ userSchema.pre('save', async function () {
46
46
  // Only hash if password is modified
47
47
  if (!this.isModified('password')) {
48
- return next();
48
+ return;
49
49
  }
50
50
 
51
- try {
52
- const salt = await bcrypt.genSalt(10);
53
- this.password = await bcrypt.hash(this.password, salt);
54
- next();
55
- } catch (error) {
56
- next(error);
57
- }
51
+ const salt = await bcrypt.genSalt(10);
52
+ this.password = await bcrypt.hash(this.password, salt);
58
53
  });
59
54
 
60
55
  // Method to compare passwords