Skip to content

Commit

Permalink
fix(users): prevent crash on non-existent users for the auth middleware
Browse files Browse the repository at this point in the history
Prevent crashing when checking the property lastPasswordChangedAt for null users
  • Loading branch information
sg-gs authored Apr 26, 2024
1 parent c413050 commit e080a37
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/config/initializers/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ module.exports = (App, Config) => {

App.services.User.FindUserObjByEmail(email)
.then((user) => {
if (!user) {
return done(new Error("User not found"));

Check failure on line 170 in src/config/initializers/middleware.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Strings must use singlequote
}

const userWithoutLastPasswordChangedAt = user.lastPasswordChangedAt === null;
const userWithLastPasswordChangedAtLowerThanToken =
user.lastPasswordChangedAt &&
Expand Down

0 comments on commit e080a37

Please sign in to comment.