Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
484 B
2
Indexable
// controller login
const auth = require('../utils/auth');

const controllerLogin = 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 auth.loginAuth(email, password);
  if (!token) {
    return res.status(400).json({ message: 'Invalid fields' });
  }
  return res.status(200).json({ token });
};

module.exports = { controllerLogin };
Leave a Comment