Minor refactoring in DB modules for readability

This commit is contained in:
Alex Holliday committed 2024-11-03 11:48:27 +08:00
1 parent 568372f54d
commit e36abfb9df
3 files changed
+28 -29

No files matched your search

+2 -3
View File
@@ -70,11 +70,10 @@ const getUserByEmail = async (email) => {
// Need the password to be able to compare, removed .select()
// We can strip the hash before returning the user
const user = await UserModel.findOne({ email: email }).select("-profileImage");
if (user) {
return user;
} else {
if (!user) {
throw new Error(errorMessages.DB_USER_NOT_FOUND);
}
return user;
} catch (error) {
error.service = SERVICE_NAME;
error.method = "getUserByEmail";