diff --git a/server/src/service/business/userService.js b/server/src/service/business/userService.js index 612f97a5a..1e9abe4b2 100644 --- a/server/src/service/business/userService.js +++ b/server/src/service/business/userService.js @@ -85,12 +85,12 @@ class UserService { // Check if user exists try { const user = await this.db.userModule.getUserByEmail(email); - + // Add null check before password comparison if (!user || !user.comparePassword) { throw this.errorService.createAuthenticationError(this.stringService.authIncorrectPassword); } - + // Compare password const match = await user.comparePassword(password); if (match !== true) { @@ -117,7 +117,7 @@ class UserService { error: error.message, stack: error.stack, }); - + // If user is not found, throw a generic authentication error for security // Don't reveal whether user exists or password is wrong throw this.errorService.createAuthenticationError(this.stringService.authIncorrectPassword); @@ -132,12 +132,12 @@ class UserService { updates.email = currentUser.email; // Get user const user = await this.db.userModule.getUserByEmail(currentUser.email); - + // Add null check before password comparison if (!user || !user.comparePassword) { throw this.errorService.createAuthorizationError(this.stringService.authIncorrectPassword); } - + // Compare passwords const match = await user.comparePassword(updates?.password); // If not a match, throw a 403