Untitled

mail@pastecode.io avatar
unknown
plain_text
25 days ago
543 B
5
Indexable
Never
// 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