import {Users} from "../../models/index";
import userNotFound from '../../utils/customErrors/userNotFound';

module.exports = async (req, res, next) => {


    const user = await Users.findOne( { where: {email: req.body.email} } );

    if(!user) {
        next(new userNotFound());
    }else {
        Object.assign(req.body, {
            id: user.id,
            role: user.role,
            name: user.name,
            rightPassword: user.password
        });
        next();
    }


};