Untitled

 avatar
unknown
plain_text
a year ago
543 B
5
Indexable
// CAMINHO DO ARQUIVO: SRC/CONTROLLERS/login.controller.js

const userAuthenticate = require('../helpers/authenticate');

const loginController = async (req, res) => {
  const { email, password } = req.body;
  if (!email || !password) {
    return res.status(400).json({ message: 'Some required fields are missing' });
  }
  const token = await userAuthenticate(email, password);
  if (!token) {
    return res.status(400).json({ message: 'Invalid fields' });
  }
  return res.status(200).json({ token });
};

module.exports = loginController;
Leave a Comment