const userModel = require("../models/user");
const bcrypt = require("bcrypt");

const validateUser = async (req) => {
    let { email } = req.body;
    email = email?.toLowerCase();
    const exists = await userModel.findOne({ email: email });
    console.log("validate :", exists);
    if(!exists){
        return false
    } else {
        return true
    }
};

const verifyPassword = async (password, hash) => {
    const match = await bcrypt.compare(password, hash);
    console.log("testing", match);
    return match;
}; 

module.exports = {
    validateUser,
    verifyPassword
}