You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PROBLEM
As of Mongoose V5.5.3+, use of the .remove() function on documents was deprecated, and should no longer be used, it will throw an error for a non-existent function.
ERROR ERROR: POST /v1/auth/logout 500 - 43.461 ms - message: refreshTokenDoc.remove is not a function
FIX
Anyone updating their mongoose with this project should use .deleteOne() instead. This project utilizes the deprecated .remove() in two locations within auth.service.js, and one location in the user.service.js
auth.service.js LINES 27 - 33
constlogout=async(refreshToken)=>{constrefreshTokenDoc=awaitToken.findOne({token: refreshToken,type: tokenTypes.REFRESH,blacklisted: false});if(!refreshTokenDoc){thrownewApiError(httpStatus.NOT_FOUND,'Not found');}awaitrefreshTokenDoc.remove();// DEPRECATED, REPLACE WITH await refreshTokenDoc.deleteOne();};
auth.service.js LINES 40 - 52
constrefreshAuth=async(refreshToken)=>{try{constrefreshTokenDoc=awaittokenService.verifyToken(refreshToken,tokenTypes.REFRESH);constuser=awaituserService.getUserById(refreshTokenDoc.user);if(!user){thrownewError();}awaitrefreshTokenDoc.remove();// DEPRECATED, REPLACE WITH await refreshTokenDoc.deleteOne();returntokenService.generateAuthTokens(user);}catch(error){thrownewApiError(httpStatus.UNAUTHORIZED,'Please authenticate');}};
user.service.js LINES 73 - 80
constdeleteUserById=async(userId)=>{constuser=awaitgetUserById(userId);if(!user){thrownewApiError(httpStatus.NOT_FOUND,'User not found');}awaituser.remove();// DEPRECATED, REPLACE WITH await user.deleteOne();returnuser;};
The text was updated successfully, but these errors were encountered:
PROBLEM
As of Mongoose V5.5.3+, use of the
.remove()
function on documents was deprecated, and should no longer be used, it will throw an error for a non-existent function.ERROR
ERROR: POST /v1/auth/logout 500 - 43.461 ms - message: refreshTokenDoc.remove is not a function
FIX
Anyone updating their mongoose with this project should use
.deleteOne()
instead. This project utilizes the deprecated .remove() in two locations within auth.service.js, and one location in the user.service.jsauth.service.js LINES 27 - 33
auth.service.js LINES 40 - 52
user.service.js LINES 73 - 80
The text was updated successfully, but these errors were encountered: