({
email,
password,
}: {
email: string;
password: string;
})
| 13 | } |
| 14 | |
| 15 | export async function validatePassword({ |
| 16 | email, |
| 17 | password, |
| 18 | }: { |
| 19 | email: string; |
| 20 | password: string; |
| 21 | }) { |
| 22 | const user = await UserModel.findOne({ email }); |
| 23 | |
| 24 | if (!user) { |
| 25 | return false; |
| 26 | } |
| 27 | |
| 28 | const isValid = await user.comparePassword(password); |
| 29 | |
| 30 | if (!isValid) return false; |
| 31 | |
| 32 | return omit(user.toJSON(), "password"); |
| 33 | } |
| 34 | |
| 35 | export async function findUser(query: FilterQuery<UserDocument>) { |
| 36 | return UserModel.findOne(query).lean(); |
no test coverage detected